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 |
|
nomiansari
Starting Member
2 Posts |
Posted - 2008-07-22 : 13:16:06
|
| Hi friendsam stuck at some point in MS SQL Server 2005 as am new to SQL.Scenerio: I have two tables, let tableA & tableB. These can be joined on tableA.id = tableB.id. Am trying to update tableA.salary for all id's for which tableB.grade = 'A' . am runnning the following queryupdate tableAset tableA.salary = xxxxxxwhere exists (select tableA.id from tableA join tableB on tableA.id = tableB.id where tableB.grade = 'A')What its actually doin is updating all the records regardless of the EXIST condition i-e it didn't update only the reqired rows but all. I have tried changing the SELECT statement like using * or other column names but in vain. Am I wrong at writing query or there exists some else solution to my case?I appreciate ur responsesthanksNoman |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-22 : 13:17:42
|
| update taset ta.salary=xxxxfrom tableA tainer join tableB tbon ta.id = tb.idwhere tb.grade='A' |
 |
|
|
nomiansari
Starting Member
2 Posts |
Posted - 2008-07-22 : 13:40:27
|
| thanks friend :) it worked just as I wannit |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-22 : 13:43:30
|
you're welcome glad that i could help you out |
 |
|
|
|
|
|