=
只有在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.gxlcms.com/article/167218.htm
总结
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com