删除表中所有 GroupID = ID 特征的信息,
比如
ID GroupID
1 0
2 1
3 2
4 3
也就是只要每条记录的GroupID能找到ID的都要删
是不是得用递归?
-- 示例
-- 示例数据
create table tb(ID int,GroupID int)
insert tb select 1,0
union all select 2,1
union all select 3,2
union all select 4,3
go
-- 删除
delete a from tb a
where exists(
select * from tb where ID=a.GroupID)
-- 结果
select * from tb
go
-- 删除测试
drop table tb
/*--结果
ID GroupID
----------- -----------
1 0
--*/