sql查询存在一张表而不存在另外一张表的三种方法

1. select distinct A.ID from  A where A.ID not in (select ID from B);
2. select A.ID from A left join B on A.ID=B.ID where B.ID is null;
3. select * from  B where (select count(1) as num from A where A.ID = B.ID) = 0

猜你喜欢

转载自blog.csdn.net/shfei10100/article/details/77930238