How to declare variables and assign values in MySQL?
In MySQL, you can use the “SET” command to declare variables and assign values.
Here are some examples of grammar.
SET @变量名 = 值;
For example, declare a variable named “myVariable” and assign it a value of 10.
SET @myVariable = 10;
You can also declare multiple variables in one statement, as shown below:
SET @variable1 = value1, @variable2 = value2, ...;
For example, declare two variables “var1” and “var2” and assign them values of 20 and 30 respectively.
SET @var1 = 20, @var2 = 30;