我正试图基于此表中的另一个值更新tablecolumn,但始终收到一个错误。
我的问题如下:

    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

最佳答案

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子句。以及使用别名以提高可读性。

关于mysql - 根据表中的值更新表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37343812/

10-09 20:59