MySQL更新事件触发插入

时间:2013-01-30 04:25:05

标签: mysql phpmyadmin

简单地说,我有以下每1分钟运行的事件:

UPDATE ticket SET status ='4'
WHERE duedate <= now()

现在我需要创建一个触发器,以便在update出现insert时将ticketID票证datetime与{{1}}一起发送到某个表格(活动表的种类) )。这可能吗?

1 个答案:

答案 0 :(得分:1)

我认为这对你有用........

mysql> delimiter $$
mysql> CREATE TRIGGER Employee_Trigger
    -> AFTER UPDATE ON employee
    -> FOR EACH ROW
    -> BEGIN
    -> INSERT into Employee_log
    -> (user_id, description)VALUES (user(),
    -> CONCAT('Id with ',NEW.id,' is modified ',
    -> ' from ',OLD.start_date, ' to ', NEW.start_date));
    ->  END$$

请参阅此链接(http://www.roseindia.net/sql/trigger/mysql-trigger-after-update.shtml