We help IT Professionals succeed at work.

update a table from another table

Bobby
Bobby asked
on
96 Views
Last Modified: 2018-08-23
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

Scott PletcherSenior DBA
CERTIFIED EXPERT
Most Valuable Expert 2018
Distinguished Expert 2019

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
CERTIFIED EXPERT
Most Valuable Expert 2018
Distinguished Expert 2019

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:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I also should have pointed out MySQL at first. Sorry about that.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.