当前你好,我的触发器更新表更新,我需要改变它只在特定列更改时触发。列更改触发器更新
代码: 创建触发器钱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
@edit
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;
$$
WHERE'current'.'thing_cost' ='things'.'thing_cost' –