大家好,又见面了,我是你们的朋友全栈君。
意思是不能再同一个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='刘老师')
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/106217.html原文链接:https://javaforall.cn