laika222
10/27/2016 - 5:44 PM

Line 1 creates a Session Variable (only used in your session - if you start a new session, the value of this variable won't be there any lon

Line 1 creates a Session Variable (only used in your session - if you start a new session, the value of this variable won't be there any longer) called multiplier1 and sets the value to 2. Line 2 shows you how to see what the value of multiplier1 will be - it will show you a value of 2 that we set in line 1. Line 5 shows how to set and show a variable in a single line using ':=' . This statement will create the variable and then show you the value 2.

Line 10 shows how you can create a variable out of other variables.

SET @multiplier1 = 2;
SELECT @multiplier1;


SELECT @multiplier5 := 2;


SET @multiplier8 = 2;
SET @multiplier9 = 3;
SET @multiplier10 = (@multiplier8 + @multiplier9);