Solved

MySQL Update with data from another database/table?

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

808 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