Learning how to create and assign values to variables

In order to create and assign a value to a variable, you use the SET statement. There are two variations of assigning a value to a variable: 

  • SET @varname = value; 
  • SET @varname := value; 

You can also set a variable with a SELECT statement, as shown in the following code sample: 

SELECT @varname := column1 FROM tablename;

You can name your variable what you like. Variable names are not case-sensitive. You can name it @varname and then use @VARname in a query when referencing the variable name, and it will work.

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

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