MySQL has two types of variables: local variables and Session-level variables: most configuration options of www.2cto.com MySQL have corresponding Session-level or Global-level variables which can be changed in client programs such as mysql, thus affecting MySQL's response to mysql connection and setting Global-level variables, the impact is that session-level variables are set for all mysql connections connected to the server. The impact is that the server's response to the current connection sets the system level. The two variables are set @ global. var_name =; set @ session. var_name =; User: You can set custom variables to store the data to be reused, so that local variables can be used in subsequent programs: declare with declare, it can only be used in the in end statement block and must be defined at the beginning of the begin end statement block. It is usually used in storage programs such as 01 create procedure sp1 (x VARCHAR (5 )) 02 BEGIN03 DECLARE xname VARCHAR (5) DEFAULT 'bob'; 04 DECLARE newname VARCHAR (5); 05 DECLARE xid INT; 06 www.2cto.com 07 SELECT xname, id INTO newname, xid08 FROM table1 WHERE xname = xname; 09 SELECT newname; 10 END; session-level variable: Also called session variable, set with set, all variables that can be used in the following sections can be used: 1 SET @ t1 = 0, @ t2 = 0, @ t3 = 0; 2 SELECT @ t1: = (@ t2: = 1) + @ t3: = 4, @ t1, @ t2, @ t3; Author: Liu Yun Zhuge