Trigger :Add an old value with the new value
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.
(TRIED WITH BEFORE UPDATE )
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
Subject
Views
Written By
Posted
Trigger :Add an old value with the new value
851
January 21, 2021 03:36AM
380
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.