Solved

MySQL Update with data from another database/table?

Posted on 2009-06-28
1
465 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get the data all row not only one row php 4 51
MySQL: Updating SubQuery Match Faster 9 46
myqsl update statement on phpMyAdmin 8 22
update joined tables 2 31
Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

16 Experts available now in Live!

Get 1:1 Help Now