MySQL中“:=”和“=”的区别浅析

=

只有在set和update时才是和:=一样,赋值的作用,其它都是等于的作用。鉴于此,用变量实现行号时,必须用:=。

:=

不只在set和update时时赋值的作用,在select也是赋值的作用。

  下面是:=和=的在select时作用对比

sql

?
1 2 set @num = 0; SELECT @num := @num+1 AS rowno, nc as nickname from table_user;

结果

MySQL中“:=”和“=”的区别浅析

sql

?
1 2 set @num = 0; SELECT @num = @num+1 AS rowno, nc as nickname from table_user;

结果

MySQL中“:=”和“=”的区别浅析

sql

?
1 2 set @num = 0; SELECT @num = @num AS rowno, nc as nickname from table_user;

结果

MySQL中“:=”和“=”的区别浅析

参考文献:https://www.jb51.net/article/167218.htm

上一篇:mimikatz记录


下一篇:反弹shell