troubleshooting Question

subquery? Update column in one table with value from another table

Avatar of aberns
abernsFlag for United States of America asked on
DatabasesMySQL ServerSQL
2 Comments1 Solution2362 ViewsLast Modified:
Using MySQL, I am trying to update one column in Table1 with the value from another column in  Table2. I guess I need a subquery, but I am not sure how to go about it.  Previously, there was not an autoincrement primary key in the Table2. Instead, the primarykey was derived from meta data. So, to fix this problem, I added an autoincrement primary key to each Table2 record. But now I have to update each Table1 record with the new primary key from Table2. The match can be the OLD primary key (the derived one), which is in both tables. Note, the old faux primary key is a VARCHAR, not an integer, if that matters.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros