my first query
SELECT ID FROM wp_posts
WHERE post_type = 'post' AND post_status = 'publish'
AND ID IN (Select object_id FROM wp_term_relationships, wp_terms
WHERE wp_term_relationships.term_taxonomy_id =18)
ORDER BY post_date DESC
produce result
31 and 28
and my second query
SELECT ID FROM wp_posts
WHERE post_type = 'post' AND post_status = 'publish'
AND ID IN (Select object_id FROM wp_term_relationships, wp_terms
WHERE wp_term_relationships.term_taxonomy_id =8)
ORDER BY post_date DESC
will produce
31 and 33
I need to get intersection of both query result.ie, 31 only. how can we get it using mysql
An intersect is nothing more than an inner join, actually:
From the top of my head. I just copy & pasted your queries, btw.