update a table from another table

Bobby
Bobby used Ask the Experts™
on
I have a table named entries. I have another table named entries2. In each table there is an id column and a content column. I need to replace all the content in table entries with all the content from table entries2. They tie together by column id.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Scott PletcherSenior DBA
Most Valuable Expert 2018
Top Expert 2014

Commented:
UPDATE e
SET content = e2.content
FROM dbo.entries e
INNER JOIN dbo.entries2 e2 ON e2.id = e.id

Author

Commented:
In SQLyog I get an error with that (I put the actual names in, you'll see that difference, was trying to keep it simple before)...

1 queries executed, 0 success, 1 errors, 0 warnings

Query: UPDATE e SET body = e2.body FROM dbo.bolt_entries e INNER JOIN dbo.bolt_entries2 e2 ON e2.id = e.id

Error Code: 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 dbo.bolt_entries e
INNER JOIN dbo.bolt_entries2 e2 ON e2.id = e.id' at line 3
Scott PletcherSenior DBA
Most Valuable Expert 2018
Top Expert 2014

Commented:
Sorry, I used SQL Server syntax, by habit I assumed that.

I'm not sure how to do that in MySQL.  Hopefully someone else can help.
Commented:
I figured it out...

UPDATE bolt_entries
INNER JOIN bolt_entries2 ON bolt_entries.id = bolt_entries2.id
SET bolt_entries.body = bolt_entries2.body;

Thanks for your help though.

Author

Commented:
I also should have pointed out MySQL at first. Sorry about that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial