时间:2021-03-28 09:18:00 | 栏目: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;
结果
参考文献:https://www.jb51.net/article/167218.htm
总结