表A
id userid
1 2
2 2
3 5我想根据userid删掉id为1和2的记录,下面这么写为什么错了,说子查询返回的值不止一个delete from A where id in (select id from A where userid=2)
id userid
1 2
2 2
3 5我想根据userid删掉id为1和2的记录,下面这么写为什么错了,说子查询返回的值不止一个delete from A where id in (select id from A where userid=2)
GO
insert into #表A
select 1, 2 union all
select 2, 2 union all
select 3, 5 delete from #表A where id in (select id from #表A where userid=2)
(2 行受影响)select * from #表A
/*
id userid
3 5
*/