代码为:
update tuition
set tuitiontwo=tuitiontwo-17
where classid=(select classid from class where coursedate=DATENAME(weekday, getdate()))可以简化为:
update 表1
set 字段1=字段1-17
where 字段2=(select 字段2 from 表2)--这里会查询出多条记录这个时候会报错:
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
语句已终止。我应该怎么写呢?求教各位!谢谢!
set tuitiontwo=tuitiontwo-17
where classid in (select classid from class where coursedate=DATENAME(weekday, getdate()))
set tuitiontwo=tuitiontwo-17
where classid in(select classid from class where coursedate=DATENAME(weekday, getdate()))
set a.tuitiontwo=a.tuitiontwo-17
from tuition a join class b on a.classid=b.classid where b.coursedate=DATENAME(weekday, getdate())