读书人

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

发布时间: 2012-03-26 15:46:55 作者: rapoo

一个简单查询语句看看要怎么写。,。
有两个表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)

读书人网 >SQL Server

热点推荐