带有INNER JOIN的MySQL Update语句

时间:2016-10-10 13:27:23

标签: mysql

我不知道问题是什么。有什么想法吗? 我尝试从评分表中更新我的first_q列。

UPDATE gradings g set g.first_q = 90 FROM gradings
INNER JOIN subjects ss
on ss.subject_id = g.subject_id
INNER JOIN students s
ON s.id = g.student_id
INNER JOIN school_years sy
on sy.id = g.sy_id
INNER JOIN teachers t
on t.id = g.teacher_id
WHERE s.id = 1;

2 个答案:

答案 0 :(得分:1)

语法错误。也许你应该尝试这样的事情:

  

更新评分g   INNER JOIN科目ss   在ss.subject_id = g.subject_id上   INNER JOIN学生   ON s.id = g.student_id   INNER JOIN school_years sy   在sy.id = g.sy_id上   INNER JOIN老师   在t.id = g.teacher_id上   设置g.first_q = 90   WHERE s.id = 1;

MYSQL Update Statement Inner Join Tables

答案 1 :(得分:0)

我相信你可以删除FROM gradings并将JOIN放在SET

之前