«

MySQL如何用LEFT JOIN更新学生表中每个学生的最高成绩?

时间:2025-1-8 08:16     作者:emer     分类:


如何在 中使用 left join 更新多个结果中的最大值?

问题:

已知以下 two tables:

如何使用 mysql 更新 student 表中每个学生的 score 字段为 score 表中对应学生成绩的最高分?

答案:

update student set score=(select max(score) from score where score.student_id=student.id)
登录后复制

以上就是MySQL如何用LEFT JOIN更新学生表中每个学生的最高成绩?的详细内容,