I have one array with the term_id.
$termID = array(165,166,158,157);
I want get ID of posts that they have all elements this array.(Get all posts that they are in the all categories with term_id 165,166,158,157). Name of my category is newcat.
I wrote :
SELECT r.object_id
FROM wp_term_relationships r
LEFT JOIN wp_term_taxonomy t ON r.term_taxonomy_id = t.term_taxonomy_id
WHERE t.term_id IN (165,166,158,157)
GROUP BY r.object_id
but I get object_id that they have one or more elements of this array.