You may declare and use variables within a routine.
DECLARE var_name[,...] type [DEFAULT value]
This command is used to declare local variables. The scope of a variable is within the BEGIN ... END block.
SET variable = expression [,...]
The SET statement in stored procedures is an extended version of the general SET command. Referenced variables may be ones declared inside a routine, or global server variables.
The SET statement in stored procedures is implemented as part of the pre-existing SET syntax. This allows an extended syntax of SET a=x, b=y, ... where different variable types (locally declared variables, server variables, and global and session server variables) can be mixed. This also allows combinations of local variables and some options that only make sense for global/system variables; in that case the options are accepted but ignored.
SELECT column[,...] INTO variable[,...] table_expression
This SELECT syntax stores selected columns directly into variables. Therefore, only a single row may be retrieved. This statement is also extremely useful when used in combination with cursors.
SELECT id,data INTO x,y FROM test.t1 LIMIT 1;