I find when I select one avg(column) into a variable,it is OK.But when I select more than one avg into a variable,it is wrong.I do not want to write it twice,how to fixed it?
//work well
SELECT
avg(MathPoint) into MathPoint
from student
where sex=1
SELECT
avg(EnglishPoint) into EnglishPoint
from student
where sex=1
//do not work
SELECT
avg(EnglishPoint) into EnglishPoint,
avg(MathPoint) into MathPoint,
from student
where sex=1
You have syntax error on
INTO
usage.INTO
should follow all variable names together after selecting fields.Example:
Documentation:
SELECT ... INTO var_list
selects column values and stores them into variables.