Learning how to use variables in SQL statements

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. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.27.45