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.
Author |
Topic |
RiyaSen845
Starting Member
3 Posts |
Posted - 2013-12-12 : 20:41:44
|
I want to compare two table columns,get the common data and update the values of ID & Flag columns in to 3rd & 4th column of the 1st table TABLE 1------------------------------------name fullname ID FLAG------------------------------------AAA AAAAAA NULL BBB BBBBBB NULLCCC CCCCCC NULLDDD DDDDDD NULLEEE EEEEEE NULLFFF FFFFFF NULLTABLE 2------------------------------------name fullname ID FLAG------------------------------------AAA AAAAAA 1 YBBB BBBBBB 2DDD DDDDDD 4 YEEE EEEEEE 5 YRESULT OF TABLE 1------------------------------------name fullname ID FLAG------------------------------------AAA AAAAAA 1 YBBB BBBBBB 2 CCC CCCCCC NULLDDD DDDDDD 4 YEEE EEEEEE 5 YFFF FFFFFF NULLCould anyone please help on this? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-12 : 20:46:22
|
[code]UPDATE t1SET ID = t2.ID, FLAG = t2.FLAGFROM TABLE1 t1 INNER JOIN TABLE2 t2 ON t1.name = t2.name and t1.fullname = t2.fullname[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|