Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL Update with data from another database/table?

Posted on 2009-06-28
1
Medium Priority
?
479 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:
K V earned 2000 total points
ID: 24734236
try:
Update a,b set a.code=b.code where a.id=b.id;
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

916 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