HIII
我有两张桌子
Invited
Active
我想删除Invited
表格中存在的Active
的UID
我可以使用加入来执行此操作,或者唯一的方法是使用NOT IN or IN
?
答案 0 :(得分:4)
是的,您可以使用IN
。
Delete From Invited where UID in (Select UID From Active)
如果您想
,也可以使用加入Delete i
From Invited as i
Join Active as a on i.UID = a.UID
答案 1 :(得分:2)
DELETE FROM `Invited` WHERE Invited.UID IN ( SELECT UID FROM `Active`)
或者,为了提高绩效:
DELETE i FROM `Invited` AS i WHERE EXISTS ( SELECT 1 FROM `Active` WHERE Active.UID = i.UID )