• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Update based on Select

I think that this is really easy, I just have never done it before.

Basically I have a two columned table: table1

It has the columns id, and name

talble1: (all have names)
-id
-name

Then I have

table2: (Some names are null)
-id
-name

I basically want to go through table2 and for any null names use the id to look up the name in table1 and then update table2 with this name.

Thanks

~Matthew
0
Zeman4323
Asked:
Zeman4323
1 Solution
 
Mr_PeerapolCommented:
UPDATE table2
SET name = b.name
FROM table2 a INNER JOIN table1 b ON a.id = b.id
WHERE a.name IS NULL
0
 
Zeman4323Author Commented:
Perfect!


Thanks so much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now