MySQL update语句 left join 怎么取多条数据中某字段最大的一条?

student表

idnamescore
1小明
2小红

score表

idstudent_idscore
1180
2288
3178
4298

想要把 student 表的 score 字段更新成 score 表里最大的那个值应该怎么写

阅读 1.7k
1 个回答

update student set score=(select max(score) from score where score.student_id=student.id)

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题