试试这个:
select p.*
from wp_posts p,
wp_terms t, wp_term_taxonomy tt, wp_term_relationship tr
wp_terms t2, wp_term_taxonomy tt2, wp_term_relationship tr2
where p.id = tr.object_id
and t.term_id = tt.term_id
and tr.term_taxonomy_id = tt.term_taxonomy_id
and p.id = tr2.object_id
and t2.term_id = tt2.term_id
and tr2.term_taxonomy_id = tt2.term_taxonomy_id
and (tt.taxonomy = 'category' and tt.term_id = t.term_id and t.name = 'Category1')
and (tt2.taxonomy = 'post_tag' and tt2.term_id = t2.term_id and t2.name in ('Nuclear', 'Deals'))
本质上,我使用了 2 个相关子表的副本——terms、term_taxonomy 和 term_relationship。一份适用“Category1”限制,另一份适用“Nuclear”或“Deals”限制。
顺便说一句,这是一个什么样的项目,所有关于核交易的帖子?你想让我们进入一些政府名单?;)