计算成绩表中学生总成绩并填入原来的Score表中,已知有student course表
3条回答 默认 最新
Watch the clown 2023-06-09 12:43关注用个视图执行效率高一点:
CREATE VIEW student_total_score AS SELECT student.id AS student_id, SUM(score.score) AS total_score FROM student JOIN score ON student.id = score.student_id GROUP BY student.id; UPDATE score SET total_score = student_total_score.total_score FROM student_total_score WHERE score.student_id = student_total_score.student_id;本回答被专家选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 2无用