SQL数据库中查询(删除)一个表在另一个表中不存在的记录
删除A表在B表中不存在的记录
第一种方式
select * from A where not exists (select 1 from B where A.ID = B.ID)
第二种方式
select * from A where (select count(1) as num from B where B.ID = A.ID) = 0
删除只需要把select * 换为delete即可
版权声明:本文为bielaiwuyang1999原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。