如何编写(SYSDATE()-1)的语法

时间:2019-05-20 17:27:18

标签: triggers

我尝试运行代码,但在(SYSDATE()-1)上进行触发时会引发错误

create trigger ReducedBill BEFORE update ON BILL
FOR EACH ROW update BILL X set amount = amount – 100 * ( select count(*) from PHONECALL Y where Y.customerID = X.customerID and Y.Date.Month = ( sysdate() – 1 ).Month and Y.Date.Year = ( sysdate() – 1 ).Year and Y.CalledNumber in ( select phoneNumber from CUSTOMER)) where X.amount > 5000 and X.Year =(sysdate() - 1).Year and X.Month = (sysdate() - 1).Month;

在处理您的请求时发生一个或多个错误: 以下查询失败:

CREATE DEFINER=root@localhost TRIGGER before_insert_money BEFORE UPDATE ON bill FOR EACH ROW update BILL X set amount = (amount - 100) * ( select count(*) from PHONECALL Y where Y.customerID = X.customerID and Y.Date.Month = ( sysdate() – 1 ).Month and Y.Date.Year = X.Date.Year and Y.CalledNumber in ( select phoneNumber from CUSTOMER)) where X.amount > 5000 and X.Year =Y.Year and X.Month = Y.Month
  

MySQL说:#1064-您的SQL语法有误;检查   对应于您的MariaDB服务器版本的手册   在'– 1)附近使用的语法。Month和Y.Date.Year = X.Date.Year和   Y.CalledNumber in(在第1行选择电话”

0 个答案:

没有答案