column auto updated after 24 hours in mysql
CREATE EVENT reset
    ON SCHEDULE
      EVERY 1 HOUR
        DO
update T1 
set state=1 
where time &lt; date_sub(now(),interval 24 hour) 
  and (state=0 or state=2) ;


it will run in every hour