Mysql – What could I possibly be doing wrong with this update statement

MySQLupdate

UPDATE pcdbak
    SET
        pcdbak.Title = pcd.Title
    FROM pcd, pcdbak
    WHERE
        pcdbak.eCommNum = pcd.eCommNum

This was the error message:

[Err] 1064 – You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near 'FROM pcd, pcdbak WHERE pcdbak.eCommNum = pcd.eCommNum' at
line 4

Best Answer

You need to use proper UPDATE JOIN syntax

UPDATE pcdbak INNER JOIN pcd
ON pcdbak.eCommNum = pcd.eCommNum
SET pcdbak.Title = pcd.Title;

or

UPDATE pcdbak INNER JOIN pcd
USING (eCommNum)
SET pcdbak.Title = pcd.Title;

or (to fix your query, 1) remove FROM, 2) move both tables next to UPDATE)

UPDATE pcd, pcdbak
    SET
        pcdbak.Title = pcd.Title
    WHERE
        pcdbak.eCommNum = pcd.eCommNum
;

Give it a Try !!!