simplifiedDB Asked: 2013-04-26 23:35:27 +0800 CST2013-04-26 23:35:27 +0800 CST 2013-04-26 23:35:27 +0800 CST 触发器是否可以使用已删除的值更新表中的行? 772 我有一个触发器,它在插入行后更新不同表中的列: mysql>delimiter $$ mysql> create trigger status after insert on table2 FOR EACH ROW BEGIN update table1 inner join table2 ON table1.id=table2.id set table1.state=0 ; 现在我想table1.state=1在删除相同的值时重置。这可能吗? mysql trigger 1 个回答 Voted Best Answer Derek Downey 2013-04-27T05:41:02+08:002013-04-27T05:41:02+08:00 如果我正确理解您的问题,那么您想要的是after delete trigger: DELIMITER $$ CREATE TRIGGER ad_foo AFTER DELETE on foo FOR EACH ROW BEGIN update table1 SET table1.state=1 WHERE id=OLD.id; END$$ DELIMITER ; 仅插入示例:http ://sqlfiddle.com/#!2/974b4/1 插入和删除示例:http ://sqlfiddle.com/#!2/0bf72/1
如果我正确理解您的问题,那么您想要的是
after delete trigger
:仅插入示例:http ://sqlfiddle.com/#!2/974b4/1
插入和删除示例:http ://sqlfiddle.com/#!2/0bf72/1