日期:2014-05-18  浏览次数:20523 次

一个简单查询语句看看要怎么写。,。
有两个表a   b     都有一个id字段

查询a表   如果a表的id在b表里存在就不查询出来


------解决方案--------------------
有两个表a b 都有一个id字段

查询a表 如果a表的id在b表里存在就不查询出来

select * from a where id not in (select id from b)
------解决方案--------------------
select * from a where id not in (select id from b)

------解决方案--------------------
select a.* from a where not exists(select 1 from b where id=a.id)

------解决方案--------------------
select * from a where not exists (select 1 from b where b.id=a.id)