bitsCN.com
1. 测试一create table test(id int, tag int, num int);
insert into test (id, tag, num) values(1, 1, 1), (2,2, 2), (3,3,3);
update test set tag = 4, num=case when tag=4 then 4 else 3 endwhere tag=3;
select * from test;
(1)sqlserver2014的结果:
(2)MySQL的结果:
2. 测试二:更换set语句的顺序create table test(id int, tag int, num int);
insert into test (id, tag, num) values(1, 1, 1), (2,2, 2), (3,3,3);
update test set num=case when tag=4 then 4 else 3 end, tag = 4