Mysql数据库定时任务

 

1:

create event myDelete

on schedule every 1 minute starts timestamp '2011-7-5 10:36:00'

do update ju_award set authen=0 where starttime < now()

创建定时任务myDelete,每隔一分钟执行一次,开始于'2011-7-5 10:36:00', 对表ju_award的每一条记录,如果

满足starttime < now(),就做修改:authen=0

 

2:

select * from ju_award where (select timediff(endtime, starttime) from ju_award )<'00:30:00' 

 从表ju_award中选中满足此条件的记录:endtime-starttime的值小于'00:30:00' 

 

3:

select * from ju_award where (select timediff(now(), endtime) from ju_award) > '00:00:00' and flag = 0

 从表ju_award中选中满足此条件的记录:now()-endtime>'00:00:00'  并且flag=0

 

4:

create event myDelete

on schedule every 10 minute starts timestamp '2011-7-5 10:36:00'

do update ju_award set authen=0  where (select timediff(now(), endtime) from ju_award) > '00:00:00' and flag = 0

创建定时任务myDelete,每隔十分钟执行一次,开始于'2011-7-5 10:36:00', 对表ju_award的每一条记录,如果

满足now-endtime>'00:00:00' 并且flag=0,就做修改:authen=0

5:

create event myDelete

on schedule every 1 hour starts timestamp '2011-7-5 10:36:00'

do update ju_award set authen=0  where now()>endtime and flag = 0

创建定时任务myDelete,每隔一小时执行一次,开始于'2011-7-5 10:36:00', 对表ju_award的每一条记录,如果

满足now>endtime(即endtime过期) 并且flag=0,就做修改:authen=0

 

你可能感兴趣的:(mysql,数据库,任务)