日期:2014-05-17  浏览次数:20374 次

请教一个查询应该怎么联合!
表A和表B做联合查询,表A有1W数据,表B有5000数据,用字段ID做连接,怎么找出表A有的,表B没有的那5000条数据?

------解决方案--------------------
--1
select * from a where not exists(select * from b where .aid=b.id)
--2 这个要求结构一致才行
select * from a
except
select * from b

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