Tab_1
"id" "name" "addr" "country" "status"
"1" "norman" "1st" "US" "2"
"2" "kirk" "2nd" "US" "2"
Tab_2
"id" "name" "addr" "country" "pos" "total"
"1" "norman" "1st" "US" "0" "0"
"2" "kirk" "2nd" "US" "0" "0"
当状态设置为时update
,我正在使用下面的Tab_1
触发器。问题是,即使它是正确的,它也不会做任何事情。我该如何正确设置?update
Tab_2
Tab_1
0
CREATE DEFINER=`root`@`localhost` TRIGGER `tab_2_upd` AFTER UPDATE ON `tab_1`
FOR EACH ROW BEGIN
if new.status = '0' then
update tab_2 set pos = pos+1, total = total+1 where id = new.id;
//Should it be new.id or old.id? I tried both but still no luck.
end if;
END