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 |
Krilyn
Starting Member
7 Posts |
Posted - 2006-06-13 : 11:07:08
|
Trying to update the value from table A with the value from table BUpdate ASet A.Value = B.ValueFrom BWhere B.PartNumber in (Select Distinct(PartNumber) from A)Problem is they're getting updated with the same value instead of the matching value from b where the part numbers match. Any help would be greatly appreciated. Thanks. |
|
Kristen
Test
22859 Posts |
Posted - 2006-06-13 : 11:18:33
|
Your syntax will join every row in A with every row in B - and only the last one will be retained, hence it looks like you are getting only a single value.I suspect what you are after is:Update ASet A.Value = B.ValueFrom TABLE_A AS A JOIN TABLE_B AS B ON B.PartNumber= A.PartNumberWhere B.PartNumber in (Select Distinct(PartNumber) from A) Kristen |
|
|
Krilyn
Starting Member
7 Posts |
Posted - 2006-06-13 : 11:22:41
|
Thank you. For the life of me I couldn't remember how I got it the first time. Thanks again. |
|
|
|
|
|