-1

我已经在这个问题上工作了几天,并且在论坛之后搜索了论坛。对于格式化这个问题,我想出了相同的答案,但我仍然遇到同样的问题。我希望有人能提供帮助。我在此代码上收到错误 #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
4

1 回答 1

1

您正在使用带有连接语法的更新 for SQL Server,这里是 for 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 
于 2013-03-01T06:53:46.907 回答