我已经在这个问题上工作了几天,并在论坛后搜索了论坛。我已经提出了相同的答案来格式化这个问题但我继续得到同样的问题。我希望有人可以提供帮助。我在这段代码上收到错误#1064。我知道这与调用学生表有关,我无法解决错误。
UPDATE
s
SET
tot_cred = u.real_cred
FROM
student s
JOIN (
SELECT ID, SUM( credits ) real_cred
FROM takes t
JOIN course c ON t.course_id = c.course_id
WHERE grade <> 'F'
AND grade IS NOT NULL
GROUP BY ID
) u ON s.ID = u.ID
答案 0 :(得分:1)
您正在使用SQL Server
的加入语法更新,此处为MySQL
:
UPDATE student s
INNER JOIN
(
SELECT ID, SUM( credits ) real_cred
FROM takes t
INNER JOIN course c
ON t.course_id = c.course_id
WHERE grade <> 'F' AND
grade IS NOT NULL
GROUP BY ID
) u ON s.ID = u.ID
SET s. tot_cred = u.real_cred