我在这样的存储过程中有一个查询:
"DELETE FROM tbl1
WHERE id1
NOT IN (SELECT id FROM tbl2)
AND id2
NOT IN(SELECT id FROM tbl2);"
现在我想知道如何才能使用内部SELECT一次?它可以在执行速度上有效吗?
答案 0 :(得分:1)
delete from tbl1
where not exists (select 1 from tbl2 where id in (tbl1.id1,tbl1.id2))