根据此表中的值更新表

时间:2016-05-20 10:05:13

标签: mysql

我尝试根据此表中的其他值更新表列但我一直收到错误。

我的查询如下:

    UPDATE partcreditor 
    SET partcreditor.creditorid = creditor.creditorid
    FROM partcreditor
    INNER JOIN creditor ON partcreditor.creditornr = creditor.creditornr
    WHERE creditor.relgroupid = 1
    AND creditor.creditortypeid = 1

1 个答案:

答案 0 :(得分:2)

UPDATE partcreditor AS PC
INNER JOIN creditor AS CR ON PC.creditornr = CR.creditornr
SET PC.creditorid = CR.creditorid
WHERE CR.relgroupid = 1 AND CR.creditortypeid = 1

无需在更新中使用FROM子句。以及使用别名以提高可读性。