A SELECT statement that assigns a value to a variable must ... (向变量赋值的 SELECT 语句不能与数据检索操作结合使用 )

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

 

错误图示:

  

 

正确图示:

  

 

posted @ 2018-09-29 09:59  郭大侠1  阅读(616)  评论(0编辑  收藏  举报