需求:当更新列中的字段时,列中的status字段,就会+1
表结构
CREATE TABLE `test_1` (
`id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`status` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
delimiter $$
DROP TRIGGER IF EXISTS trigger_test_1;
create trigger trigger_test_1
before UPDATE
on test_1
for each row begin
set NEW.status= NEW.status+1;
END ;
$$
DELIMITER ;