Home > Database > Mysql Tutorial > MySQL的Update语句Set顺序问题_MySQL

MySQL的Update语句Set顺序问题_MySQL

WBOY
Release: 2016-06-01 13:17:52
Original
1525 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template