Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i am having two tables, i want to update value of one table where value is in second table.
I want it in one query. i have tried with two query like first to select the record and then update,
but i want in one query.
SQL
Emp_Table
Empid JobId	ManagerId

Job_Table
JobId	Designation


want to update job of employees by joining two tables. please help
Posted

1 solution

You can join two tables, try following example:

SQL
UPDATE Join1 SET Col2 = t2.Col2,
Col3 = t2.Col3
FROM Join1 t1
INNER JOIN Join2 t2 ON t1.Col1 = t2.Col1
WHERE t1.Col1 IN (1,2,3) -- your filter can be placed here
GO

try same thing on your tables.
 
Share this answer
 
Comments
DipAnikap 8-Apr-14 7:56am    
Thank u
Schatak 8-Apr-14 8:03am    
Welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900