How to update table automatically in MYSQL using TRIGGER

不想你离开。 提交于 2020-01-05 09:08:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!