Definition of mysql Stored Procedure Variables
Mysql variables:
1. DECLARE variable_name datatype (size) DEFAULT default_value;
The declaration here is equivalent to a local variable and will expire after the end.
DECLARE multiple: DECLARE x, y int default 0
2. set @ p = 1;
The session variable does not need to be declared here. mysql automatically determines the type based on the value type. This variable must be preceded by the variable name with the "@" symbol, which is called the session variable, it indicates that the entire session process is effective, which is similar to a global variable. This variable is widely used because it can share data between called stored procedures or codes as long as it is in a session (that is, a connection process of an application.
3. assign values to variables. In addition to set, you can also use the select... into... method.
Reference: http://blog.csdn.net/rdarda/article/details/7878836