gpt4 book ai didi

mysql - 触发器 - 语法错误 #1064 新/旧

转载 作者:可可西里 更新时间:2023-11-01 08:06:32 26 4
gpt4 key购买 nike

<分区>

我在这里犯了什么错误?

CREATE TRIGGER total BEFORE UPDATE ON `current` FOR EACH ROW
BEGIN
if new.`new_pay_date` <> old.`new_pay_date`
SET new.`total_cash` = new.`curr_cash` + new.`total_cash`;
end if;
END;
$$

错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET new.`total_cash` = new.`curr_cash` + new.`total_cash`; end if;' at line 4

没有

if new.`new_pay_date` <> old.`new_pay_date`
end if;

但我需要检查这个,并且只更新日期更改。

当前表:

curr_cash
new_pay_date
id_person
id_thing
total_cash

谁能帮我解决这个问题?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com