Created
July 16, 2018 19:25
-
-
Save ksaylor11/b9c7c61e055fe22853243adc96bda43c to your computer and use it in GitHub Desktop.
Finds all overlapping WordPress posts between two categories
This file contains 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 | |
posts.ID, posts.post_title | |
FROM | |
wp.hpu_posts AS posts | |
INNER JOIN | |
wp.term_relationships AS rel ON posts.ID = rel.object_id | |
INNER JOIN | |
wp.term_taxonomy AS tax ON tax.term_taxonomy_id = rel.term_taxonomy_id | |
WHERE | |
tax.term_id = 17 | |
AND posts.ID IN (SELECT | |
posts.ID | |
FROM | |
wp.posts AS posts | |
INNER JOIN | |
wp.term_relationships AS rel ON posts.ID = rel.object_id | |
INNER JOIN | |
wp.term_taxonomy AS tax ON tax.term_taxonomy_id = rel.term_taxonomy_id | |
WHERE | |
tax.term_id = 17 AND post_type = 'post') | |
AND post_type = 'post' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment