日期:2014-05-18  浏览次数:20548 次

效率删除
弱弱地问一下,两个表A,B。
A.ID B.ID
1 2
2 3
3 5
4
5
如何高效删除A表ID和B表ID不相等的记录,这里是1,4

------解决方案--------------------
delete A where not exists(select 1 from A,B where A.id = B.id)
------解决方案--------------------
SQL code

delete A where not exists(select 1 from A,B where A.id = B.id)