简体   繁体   English

如果设置了特定值,如何在一小时后在表上创建触发器以更新字段

[英]How to create a trigger on table to update field after one hour if a specific value have been set

My database stores the parking status information 1 The status field has three values (0 for empty, 1 for occupied and 2 for waiting) If the parking status remains 2 for 1 hour I want to set it to 0 and set the username field to null. 我的数据库存储了停车状态信息1状态字段具有三个值(0表示空,1表示占用,2表示等待)如果停车状态保持2表示1小时,我想将其设置为0并将用户名字段设置为null 。

Is there any way to do it with triggers. 有什么办法可以用触发器做到这一点。

You probably looking to create a Event like 你可能希望创建一个Event

CREATE EVENT myevent
ON SCHEDULE EVERY HOUR 
DO
UPDATE mytable 
SET status = 0, username = null
where status = 2;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL:在将表值设置为默认值之后,如何更新外键字段并创建关系? - MySQL: How to update foreign key field, and create a relationship, after table values have been set with default values? 在插入或更新后,如何创建MySQL触发器以使用来自另一个表中字段的数据更新表的总和 - How to create a MySQL trigger for updating a sum of a table with data from a field in another table after an on Insert or Update MySQL触发器在插入另一个表后更新一个表中的字段 - MySQL Trigger to Update a field in one table after inserting into another 值更新后触发,取决于具有相同字段和表的其他行 - Trigger after update with value depend on other row with same field and table 1小时后,如何将MySQL中的列值设置为特定值后如何重置? - How to reset a column value in MySQL after it's been set to a certain value after 1 hour? 我如何在 phpmyadmin 中创建一个触发器,插入后将更新另一个表中的字段? - How can I create a trigger in phpmyadmin, that after insert will update a field in anther table? MYSQL - 如何在表中的 UPDATE 之后创建触发器,以将另一个表中的列的值增加 +1? - MYSQL - How to create a trigger after an UPDATE in a table, to increment +1 the value of a column from another table? 如何设置插入后更新字段的触发器 - How to set a trigger which update a field after insertion 如何使用插入触发器后更新表字段? - How to update a table field using after insert trigger? 如何创建获取值表格的触发器并更新其他表格 - How to create trigger that gets value form table and update different table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM