Graphical introduction to the difference between := and = in MySQL

Graphical introduction to the difference between := and = in MySQL

The difference between := and =

=

  • 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.

If you understand the difference between = and :=, then you will understand the following phenomenon.

@num:=@num+1, := is the function of assignment, so @num+1 is executed first, and then the value is assigned to @num, so the function of row number can be correctly realized.


@num=@num+1, here = means equal, @num is not equal to @num+1, so it always returns 0. If it is changed to @num=@num, it always returns 1. In the MySQL database, 1 represents true and 0 represents false.

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:
  • A Brief Analysis of the Differences between “:=” and “=” in MySQL
  • 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

<<:  How to use Docker-compose to build an ELK cluster

>>:  Avoiding Problems Caused by Closures in JavaScript

Recommend

Linux operation and maintenance basic swap partition and lvm management tutorial

Table of contents 1. Swap partition SWAP 1.1 Crea...

How to detect file system integrity based on AIDE in Linux

1. AIDE AIDE (Advanced Intrusion Detection Enviro...

How to Change Colors and Themes in Vim on Linux

Vim is a text editor that we use very often in Li...

Detailed explanation of the wonderful CSS attribute MASK

This article will introduce a very interesting at...

Vue realizes click flip effect

Use vue to simply implement a click flip effect f...

Solution to CSS flex-basis text overflow problem

The insignificant flex-basis has caused a lot of ...

How to compile and install opencv under ubuntu

Easy installation of opencv2: conda install --cha...

Website User Experience Design (UE)

I just saw a post titled "Flow Theory and Des...

How to create Apache image using Dockerfile

Table of contents 1. Docker Image 2. Create an in...

The difference and usage of Vue2 and Vue3 brother component communication bus

Table of contents vue2.x vue3.x tiny-emitter plug...

How to view Linux ssh service information and running status

There are many articles about ssh server configur...

Vue shopping cart case study

Table of contents 1. Shopping cart example 2. Cod...

What to do if you forget the initial password when installing MySQL on Mac

Forgetting the password is a headache. What shoul...

How to understand SELinux under Linux

Table of contents 1. Introduction to SELinux 2. B...

Detailed steps for setting up a nexus server

1. The significance of building nexus service As ...