sqlserver 筛选两个表不同的数据

方法一:


select A.ID from A where (select count(1) from B where B.ID = A.ID) = 0

方法二:


select A.ID from A where not exists (select 1 from B where B.ID = A.ID)

方法三:


select A.ID from A left join B on A.ID = B.ID where B.ID is null

方法四:


select distinct A.ID from A where A.ID not in (select ID from B)

方法五:



-- 相同数据 :select A.ID from A  intersect select B.ID from B

select A.ID from A  except select B.ID from B

posted @ 2019-12-10 14:00  可爱的黑精灵  阅读(859)  评论(0)    收藏  举报