Reputation: 1
I would like the date to change as many days as is given in the "interval" when I change vacation from 0 to 1
Here I paste my sweat;)
update employee_table
set date_nastne = date_nastne + "interval"
where added = 1
Upvotes: 0
Views: 88
Reputation: 781626
Use an IF
statement in the trigger that checks if you're changing vacation
from 0
to 1
. If so, add the interval to the date_nastne
column in the employee_table
.
CREATE TRIGGER AFTER UPDATE ON przykladowa
FOR EACH ROW
IF NEW.vacation = 1 AND OLD.vacation = 0
THEN
UPDATE employee_table
set date_nastne = date_nastne + INTERVAL NEW.interval DAY
where added = 1;
END IF;
Upvotes: 2