Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Statement only updates first joined record in list

Status
Not open for further replies.

GJP55

Technical User
Joined
Feb 2, 2003
Messages
220
Location
GB
Can anybody explain why when running an update query, only one record is updated where there is a match in the join and not updated by all of the matches ?

I have a table that is being updated by the value of another table where they match account numbers.
The join is on account numbers and the table that has the values has multiple records with the same account number but only the first records value is updated ???

Code:

Update tblHist
Set Balance = Balance + A.Amount
From tblHist H
Inner join Adjustments A
On H.Accountnumber = A.Accountnumber

This will only update the accountnumber record in the history table with the first record that contains the same account number from the adjustments table (there are several matching account numbers)

Thanks


Group by h.accountnumber, t.accountnumber, amount
 
I take it the group by statement is extraneous to your update statement.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'm not as think as you confused I am.
-----------
Flabbergasted (a.): Amazed at how much weight one has gained.
-----------
Oyster (n.): One who sprinkles their conversation with Yiddish expressions.
 
Yes, that should not have been there.Please ignor it. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top