2012-12-21 56 views
-4

我有以下几类(多对多关系):SQL INNER JOIN不存在

+ post 

post_tag 

+ tag 

post_category 

+ category 

如何创建SQL查询,以检查其标签中没有类别帖子?

谢谢!

+1

你能告诉我们你的表结构吗? – Mari

回答

3
select distinct pt.tagname 
from post_tag pt 
where not exists 
     (
     select * 
     from post_category pc 
     where pc.post_id = pt.post_id 
     )