MySQL中“:=”和“=”的区别浅析
=
只有在set和update时才是和:=一样,赋值的作用,其它都是等于的作用。鉴于此,用变量实现行号时,必须用:=。
:=
不只在set和update时时赋值的作用,在select也是赋值的作用。
下面是:=和=的在select时作用对比
sql
set @num = 0; SELECT @num := @num+1 AS rowno, nc as nickname from table_user;
结果
sql
set @num = 0; SELECT @num = @num+1 AS rowno, nc as nickname from table_user;
结果
sql
set @num = 0; SELECT @num = @num AS rowno, nc as nickname from table_user;
结果
总结
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11