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 |
Brittney10
Posting Yak Master
154 Posts |
Posted - 2012-03-13 : 11:39:27
|
I need to do an update statement based on the following:I have TableA which contains ClientID, Name, and Number. I also have TableB which contains ID, ClientID, and RegIDI also have TableC which contains RegID, Name, and Number.(You can see the relationships is color). What I need to be able to do, is update TableB based on the data in TableA (which is also in TableC bridge table- this data is pre-populated)For example this what i would expect to see. TableA 12345, CompanyABC, 5312Table B101112, 12345, 67890Table C67890, CompanyABC, 5312 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-03-13 : 12:22:44
|
What would you use to join from TableA to TableC (Name and Number, Name or Number)? |
 |
|
Brittney10
Posting Yak Master
154 Posts |
Posted - 2012-03-13 : 12:24:38
|
Name and Number. quote: Originally posted by Lamprey What would you use to join from TableA to TableC (Name and Number, Name or Number)?
|
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-13 : 15:49:00
|
[code]insert into TableB(ClientID,RegID)SELECT a.ClientID,c.RegIDFROM TableA aINNER JOIN TableC cON c.Name = a.Nameand c.Number = a.Number[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|