mysql set variable from select code example
Example 1: how to create a variable in mysql
-- MySQL
SET @variable_name := value;
Example 2: how to put value in variable mysql
SET variable = (SELECT SUM(tax) FROM taxable_transactions);
Example 3: define a variable in mysql from select
SELECT salary INTO @variable1 FROM employee_info WHERE emp_id = 12345678 LIMIT 1;
SELECT salary, salary_group INTO @var1, @var2 FROM employee_info WHERE emp_id = 12345678;