Discussion:
query question
Haluk Karamete
2014-04-15 01:51:30 UTC
Permalink
I'm just curious, in this WP query, what is the number "5" referring to?

[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE
1=1 AND ( (
SELECT COUNT(1)
FROM wp_term_relationships
WHERE term_taxonomy_id IN (31,32,33,34,35)
AND object_id = wp_posts.ID
) = 5 ) AND wp_posts.post_type = 'post' AND
(wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
Jerry Milo Johnson
2014-04-15 02:19:27 UTC
Permalink
Not 100%, but I believe that 5 is being compared to the count from the
term_relationships.

There shouldn't be more than 1 result in that query for any single
taxonomy_id.

And there are 5 taxonomy_ids in the IN clause.

So I think it is returning those posts with ALL 5 taxonomy_ids.

So if a post only has 1 or 2 or 3 or 4 of those tax_ids, they are ignored.
Just if they have all 5 for that post is it included in the return set.

hth.
Jerry Milo Johnson
Post by Haluk Karamete
I'm just curious, in this WP query, what is the number "5" referring to?
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE
1=1 AND ( (
SELECT COUNT(1)
FROM wp_term_relationships
WHERE term_taxonomy_id IN (31,32,33,34,35)
AND object_id = wp_posts.ID
) = 5 ) AND wp_posts.post_type = 'post' AND
(wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...