MYSQL - 检查时间并执行查询 [英] MYSQL - check a time and execute query
本文介绍了MYSQL - 检查时间并执行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想(如果可能的话)检查一个时间,如果时间 = 特殊时间,更新表格.
I'd like (if it possible) check a time and if time = special time, make update of the table.
我的想法:
select current_time()
if current_time = 15:19
{
update tasks set finished = replace (finished, '1', '0')
}
你有什么想法吗???
推荐答案
使用 事件
delimiter //
CREATE EVENT IF NOT EXISTS your_event
ON SCHEDULE EVERY 1 DAY
STARTS '2014-07-04 15:19:00'
ON COMPLETION PRESERVE ENABLE
DO
update tasks
set finished = replace (finished, '1', '0');
//
它将每天在定义的时间自动执行.
It will be executed automatically every day on the defined time.
这篇关于MYSQL - 检查时间并执行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文