Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update query

Author  Topic 

immad
Posting Yak Master

230 Posts

Posted - 2013-12-20 : 06:24:44
this is my first table


CID-----BID---EID-----Ename-------------Phone---------CELL NO
1--------1----7--------A---------------5047183-----03138236415
1--------1----15-------B---------------5045107-----03212634704

this is my second table

CID-----BID---EID-----Ename-------------Phone---------CELL NO
1--------1----7---------A------------------------------------
1--------1----15--------B------------------------------------

i want a query to update my second table from first table. like this

after execute query my second table look like this

CID-----BID---EID-----Ename-------------Phone---------CELL NO
1--------1----7--------A---------------5047183-----03138236415
1--------1----15-------B---------------5045107-----03212634704


thanks 4 the help

immad uddin ahmed

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-12-20 : 06:54:31
try this:

update t2
set Phone = t1.Phone,
Cell_No = t1.Cell_No
from first_table t1
join second_table t2
on t1.CID = t2.CID and
t1.BID = t2.BID and
t1.EID = t2.EID and
t1.Ename = t2.Ename



Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -