意思是不能再同一个sql语句中对同一个表先查询在更新,
解决办法是在查询部分的语句中加上别名;错误的如下:
update Sc set score =(
select avg(sc2.score) aa from sc sc2 ,course where sc2.c=course.c
)
where c in
(select c from test.course cs inner join test.teacher th on cs.T=th.T and th.Tname='刘老师')
正确的如下:对第二行的查询结果加上别名a就行了
update Sc set score =(
select a.aa from (
select avg(sc2.score) aa from sc sc2 ,course where sc2.c=course.c
) a)
where c in
(select c from test.course cs inner join test.teacher th on cs.T=th.T and th.Tname='刘老师')