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

Summary of seven MySQL JOIN types

Before we begin, we create two tables to demonstr...

The front-end must know how to lazy load images (three methods)

Table of contents 1. What is lazy loading? 2. Imp...

Share JS four fun hacker background effect codes

Table of contents Example 1 Example 2 Example 3 E...

Detailed explanation of Vue routing router

Table of contents Using routing plugins in a modu...

How to modify mysql permissions to allow hosts to access

Enable remote access rights for mysql By default,...

Randomly generate an eight-digit discount code and save it to the MySQL database

Currently, many businesses are conducting promoti...

Computed properties and listeners details

Table of contents 1. Calculated properties 1.1 Ba...

The hottest trends in web design UI in 2013 The most popular UI designs

Time flies, and in just six days, 2013 will becom...

How to change the character set encoding to UTF8 in MySQL 5.5/5.6 under Linux

1. Log in to MySQL and use SHOW VARIABLES LIKE &#...

How to call the interrupted system in Linux

Preface Slow system calls refer to system calls t...

JavaScript to implement a simple clock

This article example shares the specific code for...

Nginx operation and maintenance domain name verification method example

When configuring the interface domain name, each ...

How to quickly build a static website on Alibaba Cloud

Preface: As a junior programmer, I dream of build...

A brief discussion on common operations of MySQL in cmd and python

Environment configuration 1: Install MySQL and ad...