Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5530

Davinder Singh on "how to select single post with multiple term_id mysql"

$
0
0

Hi all,

Hope all are doing great :)

I am having a situation where i need the conjunction of term ids.

i want to select the post haing both the terms assigned to it.

I have tried this :-

SELECT p.ID,p.post_title,p.guid FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON p.ID = tr.object_id LEFT JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN wp_terms AS t ON t.term_id = tt.term_id WHERE t.term_id IN (86,40) AND p.post_status = 'publish' LIMIT 0,7

But it is showing all the results of bith the ids. But i want to show the post having both.

Please help.

Thanks in advance.


Viewing all articles
Browse latest Browse all 5530

Trending Articles