【发布时间】:2012-12-03 12:49:50
【问题描述】:
我需要使用触发器自动更新我的列。
代码如下:
create trigger sum update on `cash`
for each row
begin
UPDATE `cash`
SET `sum_cash` = `cash` + `sum_cash`;
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 'update on `cash` for each row begin UPDATE cash` SE' at line 1
我在 MySQL 上工作。
【问题讨论】:
-
是
cash既是一个表,也是该表上的一个字段,例如cash.cash?您将它用作表/字段,不清楚是否这是设计使然。 -
是的,既是字段又是名称
-
您真的要更新表的 所有 行吗?