Both SQL server and mysql are our frequently used database systems. Next we will introduce the differences between the values of SQL server and mysql variables, and hope to enlighten you.
Variables in SQL server must be affirmed first and then assigned values:
The local variables are identified with one @, and the global variables with two @ common global variables are generally defined );
Declare the local variable Syntax: declare @ variable name data type; for example, declare @ num int;
Value assignment: There are two methods: @ num is the variable name, and value is the value)
Set @ num = value; or select @ num = value;
If you want to obtain a field value in the query statement, you can use select to assign values to the variable, as shown below:
Select @ num = field name from table name where ......
You do not need to declare the value assignment of mysql variables beforehand. You can simply use "@ variable name" when using it.
First usage: set @ num = 1; or set @ num: = 1; // use the variable to save the data. Use the @ num variable directly.
Second usage: select @ num: = 1; or select @ num: = field name from table name where ......
Note that the above two values can be set with "=" or ": =", but ": =" must be used for select"
Take you to understand MySQL random string functions
In-depth study of MySQL result strings
MySQL string truncation Function Method
Differences between MySQL string column types
Usage of MySQL user Variables