delete a from a where item not in( select item from b union select item from c union select item from d)
create table a(item int)create table b(item int)create table c(item int)create table d(item int) insert a select 1 insert a select 2 insert a select 3 insert a select 4 insert a select 5 insert b select 1 insert c select 2 insert d select 3 go ---1 delete a where not exists( select 1 from ( select item from b union select item from c union select item from d ) e where a.item = e.item) ---2 delete a from a where item not in( select item from b union select item from c union select item from d) select * from adrop table a,b,c,d/* item ----------- 1 2 3(所影响的行数为 3 行) */
from a
where item not in( select item from b union
select item from c union
select item from d)
insert a select 1
insert a select 2
insert a select 3
insert a select 4
insert a select 5
insert b select 1
insert c select 2
insert d select 3
go
---1
delete a
where not exists( select 1 from ( select item from b union
select item from c union
select item from d ) e
where a.item = e.item)
---2
delete a
from a
where item not in( select item from b union
select item from c union
select item from d)
select * from adrop table a,b,c,d/*
item
-----------
1
2
3(所影响的行数为 3 行)
*/