问题
I have a table in mysql database where I am calculating New Owed Balcance based on the interest + amount borrowed... I want it to be that when the interest is altered the new owed balace changes I am using Triggers but it does not seem to update it when the interest changes
DELIMITER |
CREATE TRIGGER updateloan BEFORE INSERT ON loan
FOR EACH ROW BEGIN
SET NEW.app_amnt_owed = NEW.app_intrst +NEW. app_ln_amnt;
END;
|
回答1:
CREATE TRIGGER updateloan_update
BEFORE UPDATE ON loan
FOR EACH ROW
SET NEW.app_amnt_owed = NEW.app_intrst + NEW.app_ln_amnt;
来源:https://stackoverflow.com/questions/9510896/how-to-update-table-automatically-in-mysql-using-trigger