MySQL database variables include MySQL System variables and MySQL user variables. The following describes the application of MySQL user variables for your reference and learning.
MySQL user variables:
Based on session variables, you can save values and pass them to the variables used by the next SQL statement in the same connection.
When the client connection exits, the variable is released.
Application scenarios of MySQL user variables:
If the same connection is not closed, some computation results will be saved for you.
For example
Select @ admin_id: = max (id) from user_info;
Select * from user_info where id = @ admin_id
The preceding two SQL statements are completed in the same connection.
In addition, note that there is only one @ before the user variable and two @ is used to access the system variable.
Too many business-related variables are defined, so the global variables of the system cannot be distinguished?
This type of problem can be solved through the structured system variables provided by mysql.
They have a unique representation:
Instance_name.test_var
An instance_name is added to a common variable. In this way, you can easily classify them. For example, app. test_var can be different from the system var.
Use of MySQL System Variables
Difference between NULL and MySQL NULL strings
In-depth study of MySQL result strings
MySQL string truncation Function Method
Number sorting in MySQL strings