1

トリガーを使用して列を自動的に更新する必要があります。

コードは次のとおりです。

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に取り組んでいます。

4

1 に答える 1

1

これを試して:

delimiter $$
create trigger my_sum after update on `cash`
for each row
begin
UPDATE `cash`
SET `sum_cash` = `cash` + `sum_cash`;
end;
$$

afterまたはbeforeキーワードがありません。sumまた、 がキーワードであるため、トリガー名を変更しました。

于 2012-12-03T12:58:28.700 に答える