こんにちは、現在、テーブルの更新時にトリガーが更新されています。これを変更して、特定の列が変更されたときにのみ起動するようにする必要があります。
コード: 更新後にトリガー マネーを作成するthings
for each row
begin
UPDATE `current` c
INNER JOIN things t ON c.id2 = t.id2
INNER JOIN dude_base d ON d.id1 = c.is1
SET c.`curr_cash` = t.thing_cost * d.salary / 100;
end;
$$
そして、物事から「thing_cost」に更新があったときにオンになるように変更する必要があります。
@edit curr_cash と物価はまったく異なる値であることを更新する必要があります。それらを比較することはできません。それらは常に異なります。
私が使用したとき
if NEW.things_cost <> OLD.things_cost
次のエラーが表示されます。
#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 '' at line 10
@編集
create trigger wys_sk_b after update on `dude_base`
for each row
begin
if NEW.salary <> OLD.salary
then
UPDATE `current` s
INNER JOIN things u ON s.id_thing = u.id_thing
INNER JOIN dude_base b ON b.id = s.id
SET s.`curr_cash` = u.thing_cost * b.salary/ 100;
end if;
$$