效率删除
弱弱地问一下,两个表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)
发布时间: 2012-03-31 13:13:26 作者: rapoo
效率删除
弱弱地问一下,两个表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)
[解决办法]
delete A where not exists(select 1 from A,B where A.id = B.id)