A SELECT statement that assigns a value to a variable must ... (向变量赋值的 SELECT 语句不能与数据检索操作结合使用 )
总结一句话,一行语句中,要么都是赋值,要么都是查询,不能既有赋值又有查询
[ 错误 ] select @classname=classname,@chargeteacher from classes where classid=@classid
[ 错误 ] select @classname=classname,name from classes where classid=@classid
[ 正确 ] select @classname=classname,@chargeteacher=chargeteacher from classes where classid=@classid
错误图示:
正确图示: