当前位置: 代码迷 >> Sql Server >> 一个简单查询语句看看要如何写。
  详细解决方案

一个简单查询语句看看要如何写。

热度:44   发布时间:2016-04-27 19:52:37.0
一个简单查询语句看看要怎么写。,。
有两个表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)
  相关解决方案