34,576
社区成员
发帖
与我相关
我的任务
分享
declare @tb table(id int,t1id int,name varchar(20),work varchar(20))
insert into @tb select 1,1,'张三','教师'
insert into @tb select 2,1,'李四','学生'
insert into @tb select 3,2,'王五','教师'
insert into @tb select 4,3,'赵六',''
insert into @tb select 5,1,'刘七','教师'
declare @ta table(id int,school varchar(20))
insert into @ta select 1,'aa学校'
insert into @ta select 2,'bb学校'
insert into @ta select 3,'cc学校'
select * from @ta
delete from @ta
where id in (select t1id from @tb)
select * from @ta
--
--delete from @ta
--where id in (select t1id from @tb left join 表 .... where id in ....)