Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
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

share|improve this question
1  
Can you post the table schemas? Perhaps the column eCommNum does not exist? –  SQLRockstar Jul 10 '13 at 20:29
add comment

1 Answer

up vote 3 down vote accepted

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 !!!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.