Last active
April 24, 2023 19:14
-
-
Save landbryo/880ad8ee92a4e7a9ccc3acaf662a66e6 to your computer and use it in GitHub Desktop.
Combine Inner Join and IN to query data from both the posts and postmeta tables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT post_id,meta_value | |
FROM db.wp_postmeta | |
INNER JOIN db.wp_posts ON db.wp_postmeta.post_id = db.wp_posts.ID | |
WHERE post_type IN('post','page','custom_post_type') | |
AND meta_key = 'some_meta_key' | |
AND meta_value | |
IN( | |
'item1','item2','item3' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment