MySQL Forums
Forum List  »  Triggers

Trigger :Add an old value with the new value
Posted by: theo robert
Date: January 21, 2021 03:36AM

I'm trying to create an trigger on phpmyadmin. My objective is to create a trigger that add the old value of a row with the new value (inserted with a form).

It's for managing the student dues, so if a student already paid $100, and pay $150 more the other time, the trigger have to add the old value ($100) with the new received value ($150), and the field 'already_paid' in the db is now $250.

I've tried something simple like this, but it didn't worked.


SET @resultat = already_paid + new.already_paid
UPDATE student_dues
SET already_paid = @resultat
WHERE student_due_id = new.student_due_id


UPDATE student_dues
SET versement = versement + new.versement
WHERE student_due_id = new.student_due_id

Options: ReplyQuote

Written By
Trigger :Add an old value with the new value
January 21, 2021 03:36AM

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.