MySQL Forums
Forum List  »  Triggers

Re: Trigger :Add an old value with the new value
Posted by: Peter Brawley
Date: January 21, 2021 11:05AM

There seems to be a design problem---you will need to keep a record of an individual's current payment, and also a record of her total payments; the usual solution is to keep a total_paid column in an `account` table, store individual payments in another `transactions` table, and update the account sum when there are new transactions. Then a Trigger on transactions would say ...

update account
set total_paid = total_paid + new.paid
where account_id=new.account_id;

Options: ReplyQuote

Written By
Re: Trigger :Add an old value with the new value
January 21, 2021 11:05AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.