About this document
MySQL Trigger Creation and Management by sarthaksainia12 is a document available to read on EtoBox.
Here is the trigger to update the total salary in SalaryBudgets after a row is deleted from Salaries: DELIMITER $$ CREATE TRIGGER update_salary_budget AFTER DELETE ON Salaries FOR EACH ROW BEGIN UPDATE SalaryBudgets SET total = total - OLD.salary; END$$ DELIMITER ; To test it: DELETE FROM Salaries WHERE employeeNumber = 1002; SELECT * FROM SalaryBudgets; This trigger uses the OLD row to access the salary of the deleted row and subtracts it from the total in SalaryBudgets.
- Author
- sarthaksainia12
- Language
- EN