sql 查询存在一个表而不在另一个表中的数据

方法一(效率底)


select A.* from 办卡 A where A.namedh not in (select namedh from 银行)

方法二(效率中)

select A.* from 办卡 A left join 银行 b on A.namedh=B.namedh where B.namedh is null  

方法三(效率高)

select * from  办卡 A where (select count(1) as num from 银行 B where A.namedh = B.namedh) = 0
原文地址:https://www.cnblogs.com/gisoracle/p/10897679.html