MySQL中“:=”和“=”的區別淺析
阿新 • • 發佈:2020-01-09
=
只有在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,255); text-indent: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial" src="http://img.cppcns.com/pic.php?url=/file_images/article/201908/201988105324959.jpg?201978105331" />參考文獻:https://www.jb51.net/article/167218.htm
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對我們的支援。