我需要一个meta_value
来自wp\\U Posteta,我可以使用一个类别,但使用另一个类别时遇到问题。
我有:
SELECT wp_posts.ID, wp_postmeta.meta_value FROM wp_postmeta
LEFT JOIN wp_posts ON wp_posts.ID = wp_postmeta.post_id
LEFT JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id
LEFT JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE wp_postmeta.meta_key = \'_application\'
AND wp_term_taxonomy.term_id = \'14\'
我的结果是:
ID | meta_value
91 | [email protected]
99 | [email protected]
当我更改最后一行时
wp_term_taxonomy.term_id = \'14\'
到
wp_term_taxonomy.term_id = \'31\'
我将获得:
ID | meta_value
91 | [email protected]
95 | [email protected]
当我使用2个类别时,问题开始出现
SELECT wp_posts.ID, wp_postmeta.meta_value FROM wp_postmeta
LEFT JOIN wp_posts ON wp_posts.ID = wp_postmeta.post_id
LEFT JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id
LEFT JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE wp_postmeta.meta_key = \'_application\'
AND wp_term_taxonomy.term_id = \'14\'
AND wp_term_taxonomy.term_id = \'31\'
那我什么也得不到
MySQL返回一个空结果集(即零行)。
我应该得到:
ID | meta_value
91 | [email protected]
如何使用这两个类别(
term_id = \'14\'
和
term_id = \'31\'
) 同时在一个查询中,这样我的结果将只显示两个类别中的帖子的meta\\u值?