且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除表中所有在另一个表中没有引用的记录

更新时间:2022-12-10 17:04:31

您可以使用 NOT EXISTS 来查找和删除这些项目:

You can use NOT EXISTS to find and delete those items:

delete from document d
where not exists (select 1 from AppRequiredDocuments a where a.docid = d.id);
and not exists (select 1 from AppDocuments a where a.docid = d.id);