[wp-hackers] query question

Jerry Milo Johnson jmiloj at gmail.com
Tue Apr 15 02:19:27 UTC 2014


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



On Mon, Apr 14, 2014 at 9:51 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:

> 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
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list