有人可以告诉我这个查询有什么问题..? [关闭]

SELECT p.post_title FROM wp_posts p
LEFT JOIN wp_term_relationships tr on (p.ID = tr.object_id)
LEFT JOIN wp_term_taxonomy tt on (tr.term_taxonomy_id = tt.term_taxonomy_id)
LEFT JOIN wp_term_taxonomy tt2 on (tr.term_taxonomy_id = tt2.term_taxonomy_id)
WHERE 
tt2.term_id IN( 36, 32)
AND tt.term_id = 33
AND p.post_type = 'post'

Actually, i have two different taxonomy (namely status and category) each of those has many terms. there i have to check in one certain category term (that term_id 33) has how many posts whose statuses terms term_id 36 or 32.

Actually, i need to apply the condition to the same column ( of wp_term_taxonomy table) two times.

Above query return nothing.Guys, please help me out.

Don't use columns related to LEFT JOIN TABLE in WHERE condition otherwise these work as an INNER JOIN so

SELECT p.post_title FROM wp_posts p
LEFT JOIN wp_term_relationships tr on (p.ID = tr.object_id)
LEFT JOIN wp_term_taxonomy tt on (tr.term_taxonomy_id = tt.term_taxonomy_id) 
        AND tt.term_id = 33
LEFT JOIN wp_term_taxonomy tt2 on (tr.term_taxonomy_id = tt2.term_taxonomy_id) 
        AND tt2.term_id IN ( 36, 32)
  WHERE p.post_type = 'post'