A Brief Analysis of the Differences between “:=” and “=” in MySQL

A Brief Analysis of the Differences between “:=” and “=” in MySQL

=

Only when setting and updating does it have the same effect as :=, that is, assignment; otherwise it has the effect of equality. In view of this, when using variables to implement line numbers, you must use :=.

:=

It not only has the function of assigning values ​​when setting and updating, but also when selecting.

The following is a comparison of the effects of = and = in select

sql

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

result

sql

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

result

sql

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

result


Reference: https://www.jb51.net/article/167218.htm

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Explain the usage of the <=> operator in MySQL
  • MYSQL where 1=1 judgment function description
  • mysql sql_mode="" function description
  • Summary of the use of special operators in MySql
  • Graphical introduction to the difference between := and = in MySQL

<<:  Use the Linux seq command to generate a sequence of numbers (recommended)

>>:  js implements axios limit request queue

Recommend

MySQL 8.0.16 installation and configuration graphic tutorial under macOS

This article shares the installation and configur...

JS uses the reduce() method to process tree structure data

Table of contents definition grammar Examples 1. ...

Instructions for using JSON operation functions in Mysql5.7

Preface JSON is a lightweight data exchange forma...

Detailed explanation of the solution to forget the password in MySQL 5.7

ENV: [root@centos7 ~]# uname -r 3.10.0-514.el7.x8...

Detailed explanation of CSS background and border tag examples

1. CSS background tag 1. Set the background color...

Example of implementing translation effect (transfrom: translate) with CSS3

We use the translate parameter to achieve movemen...

Implementation steps for building multi-page programs using Webpack

It is very common to use webpack to build single-...

Videojs+swiper realizes Taobao product details carousel

This article shares the specific code of videojs+...

Methods and steps for deploying go projects based on Docker images

Dependence on knowledge Go cross-compilation basi...

Pure CSS to achieve cloudy weather icon effect

Effect The effect is as follows ​ Implementation ...

Solve the problem of running jupyter notebook on the server

Table of contents The server runs jupyter noteboo...

A little-known JS problem: [] == ![] is true, but {} == !{} is false

console.log( [] == ![] ) // true console.log( {} ...