mysql variable declaration and assignment
Dec 16, 2016 pm 02:06 PMVariables in sql server must be declared first and then assigned a value:
Local variables are marked with one @, and global variables are marked with two @s (commonly used global variables are generally already defined);
The syntax for declaring local variables: declare @variable Name data type; for example: declare @num int;
Assignment: There are two methods (@num is the variable name, value is the value)
set @num=value; or select @num=value;
If you want To obtain a field value in a query statement, you can use select to assign a value to a variable, as follows:
select @num=Field name from table name where...
Variables in MySQL do not need to be declared in advance. When using them, use "@variable name" directly. "Just use it.
First usage: set @num=1; or set @num:=1; //Variables are used to save data here, use @num variables directly
Second usage: select @num:=1; Or select @num:=field name from table name where...
Pay attention to the above two assignment symbols. You can use "=" or ":=" when using set, but you must use ":= assignment" when using select
The above is the content of mysql variable declaration and value assignment. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to enable copy and paste for VMware virtual machines

Disable or enable automatic copy selection for copying in Terminal

Unlock macOS clipboard history, efficient copy and paste techniques

What are the assignment methods in php?

Tips and Notes: Different String Array Assignment Methods

What are the methods of assigning values to string arrays?

Learn variable definition and assignment in Golang
