SQLServer两张表筛选相同数据和不同数据

方法一:

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

方法二:

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

方法三:

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

方法四:

SELECT * FROM b WHERE NOT EXISTS(SELECT 1 FROM a WHERE tel_no=b.tel_no)

 

方法五:

SQLServer两张表筛选相同数据和不同数据
--相同数据
select tel_no from a
intersect
select tel_no from b

--不同数据
select tel_no from b
except
select tel_no from a
SQLServer两张表筛选相同数据和不同数据

 

 

出处:https://www.cnblogs.com/onesmail/p/6148979.html

上一篇:python中list列表的高级函数


下一篇:手机号@符号的处理