Link to home
Start Free TrialLog in
Avatar of Bobby
BobbyFlag for United States of America

asked on

update a table from another table

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.
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

UPDATE e
SET content = e2.content
FROM dbo.entries e
INNER JOIN dbo.entries2 e2 ON e2.id = e.id
Avatar of Bobby

ASKER

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
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.
ASKER CERTIFIED SOLUTION
Avatar of Bobby
Bobby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bobby

ASKER

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