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

A brief analysis of the count tracking of a request in nginx

First, let me explain the application method. The...

Vue implements accordion effect

This article example shares the specific code of ...

PHP scheduled backup MySQL and mysqldump syntax parameters detailed

First, let's introduce several common operati...

Comparison of the use of form element attributes readonly and disabled

1) Scope of application: readonly:input[type="...

Why node.js is not suitable for large projects

Table of contents Preface 1. Application componen...

How to implement Vue binding class and binding inline style

Table of contents Binding Class Binding inline st...

mysql 5.7.18 winx64 free installation configuration method

1. Download 2. Decompression 3. Add the path envi...

Introduction to Docker Quick Deployment of SpringBoot Project

1. Install Docker First open the Linux environmen...

Vue based on Element button permission implementation solution

Background requirements: The ERP system needs to ...

Solve the problem of docker's tls (ssl) certificate expiration

Problem phenomenon: [root@localhost ~]# docker im...

CSS horizontal centering and limiting the maximum width

A CSS layout and style question: how to balance h...

Detailed tutorial on installing Docker on Windows

Since my local MySQL version is relatively low, I...

Detailed explanation of Nginx configuration file

The main configuration file of Nginx is nginx.con...

JavaScript canvas to achieve raindrop effect

This article example shares the specific code for...

Implementing a simple timer in JavaScript

This article example shares the specific code of ...