当我在SQL Server中执行此操作时
update table
set column = @value
where id in (1,2,2)
需要执行多少次更新操作?2 次还是 3 次,其中两次更新作用于 id=2 的行?
当我在SQL Server中执行此操作时
update table
set column = @value
where id in (1,2,2)
需要执行多少次更新操作?2 次还是 3 次,其中两次更新作用于 id=2 的行?
使用select测试你的代码,你将看到有多少行将被更新。
计数
select count(*) from table
where id in (1,2,2)
查看更新的行
select * from table
where id in (1,2,2)
declare @table table (id int, num int)
insert into @table values (1,1),(2,1)
update @table
set num = num + 1
where id in (1,2,2)
select * from @table
Result is:
id num
1 2
2 2