We help IT Professionals succeed at work.
Get Started

Need help with a MySQL UPDATE using JOIN

mrh14852
mrh14852 asked
on
466 Views
Last Modified: 2012-05-09
I have two tables

Table1
id      Product    Name1
1        ProdA       null
2        ProdB       null
3        ProdC        null
4        ProdD        null

Table2
id      Level    Product
1          1           ProdA
2          2           ProdB
3          2           ProdD

So I need to update Table1.Name1 with Table2.Level which would have this output
id      Product    Name1
1        ProdA         1
2        ProdB          2
3        ProdC        null
4        ProdD          2

This is the select query I run to find which products Name1 has associated with it.
SELECT
Table2.Level,
Table1.Product
FROM
Table1 ,
Table2
WHERE Table2.Product LIKE Table1.Product

So just trying to figure out the UPDATE syntax to update table 1.

Thanks a lot.


Comment
Watch Question
Chief Technology Officer
CERTIFIED EXPERT
Most Valuable Expert 2011
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE