Skip to content

Instantly share code, notes, and snippets.

@csaborio001
Created April 7, 2020 01:36
Show Gist options
  • Save csaborio001/327f75e3617e58ab44236511382226b7 to your computer and use it in GitHub Desktop.
Save csaborio001/327f75e3617e58ab44236511382226b7 to your computer and use it in GitHub Desktop.
SELECT
*
FROM
wp_posts
INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
LEFT JOIN (
SELECT
wp_posts.ID
FROM
wp_posts
INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
WHERE (wp_postmeta.meta_key = 'smoker' AND wp_postmeta.meta_value = 'Yes')
) smoker on smoker.id = wp_posts.ID
WHERE
smoker.ID IS NOT NULL
AND wp_posts.post_type = 'volunteer'
AND wp_posts.post_status = 'publish'
AND(wp_postmeta.meta_key = '_state'
AND wp_postmeta.meta_value = 'available')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment