当前位置:Gxlcms > mysql > MySQL的Update语句Set顺序问题_MySQL

MySQL的Update语句Set顺序问题_MySQL

时间:2021-07-01 10:21:17 帮助过:11人阅读

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<

人气教程排行