日期:2014-05-17 浏览次数:20465 次
delete from A where exists(select 1 from b where a.psg_name =b.psg_name)
create table tb(id int,val varchar(10))
insert into tb select 1,'a' union all select 2,'b' union all select 3,'c'
create table tb1(id int,val varchar(10))
insert into tb1 select 2,'a' union all select 4,'b' union all select 6,'c'
go
delete a from tb a inner join tb1 b on a.id=b.id
select * from tb
/*
id val
----------- ----------
1 a
3 c
(2 行受影响)
*/
go
drop table tb,tb1
delete from A where exists(
select 1 from B where a.PSG_NAME=B.RSP_NAME
)
delete from A where exists(select 1 from b where a.psg_name =b.rsp_name)