0

In phpMyAdmin, I want to have my code copy one field from one table to another table based on a different field that matches between the two tables. I'm missing something.

When I type:

SELECT *
FROM old_email e,
     old_contact c
WHERE e.contact_id = c.id;

I get 1793 records.

When I type:

UPDATE old_email
SET old_email.first = old_contact.first_name
FROM old_email
INNER JOIN old_contact
ON old_email.contact_id = old_contact.id

MySQL said: Documentation

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 old_email

INNER JOIN old_contact ON old_email.contact_id = old_contact.id' at line 3

Community
  • 1
  • 1
  • 1
    Hi, welcome to the forum. This have been already answered here. https://stackoverflow.com/questions/11709043/mysql-update-column-with-value-from-another-table – Digvijay S Mar 10 '20 at 14:33
  • Thank you Digvijay S. The link helped me to update my records. Not sure what the problem with my previous syntax was :o – timindaburgh Mar 10 '20 at 14:40
  • Welcome. In your SQL sequence was wrong. `UPDATE` --> `INNER JOIN` -->`ON`--> `SET`--> `WHERE` – Digvijay S Mar 10 '20 at 14:43

0 Answers0