4

I have 2 tables as :

TableA:

ID Value 1 A 2 B 

TableB:

 Rank Value 12 A 13 B 

I need to join both tables on Value column and update Value column of TableB with TableA's ID column. So result TableB will be:

Rank Value 12 1 13 2 

I am using Sql Server 2008

2
  • What datatype is Value in TableB? Commented May 19, 2014 at 20:01
  • All column data types are varchar(50) Commented May 19, 2014 at 20:01

2 Answers 2

2

Use update with join:

update b set b.value = a.id from tableb b join tablea a on b.value = a.value 
Sign up to request clarification or add additional context in comments.

Comments

0

In SQL Server, you can do this with a join in the update. The specific syntax in your case is:

update b set value = a.id from tableb b join tablea a on b.value = a.value; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.