In order to use a variable in a SQL statement, you need to place the variable name into the query, as shown in the following example:
USE lahmansbaseballdb;
SET @varname := 'ALB01';
SELECT * FROM parks_copy
WHERE parkkey = @varname;
The preceding query produces the following results:
This was a simple example that shows how to use a variable – they can be quite powerful.