Solved

MySQL Update with data from another database/table?

Posted on 2009-06-28
1
464 Views
Last Modified: 2012-05-07
I have two databases with the following content:

table a
id | x | code
1 | ABC | 14
2 | GHI | 34
3 | XYZ | 19

table b
id | M | code
1 | A2 |
3 | G8 |
5 | X0 |

I'm trying to update table b with the code for table for the records that have the same id, so I get:

id | M | code
1 | A2 |  14
3 | G8 | 19
5 | X0 |

Anyone know how to do that?
0
Comment
Question by:n00b0101
1 Comment
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 500 total points
ID: 24734236
try:
Update a,b set a.code=b.code where a.id=b.id;
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now