Surendra Singh Surendra Singh - 3 months ago 21
MySQL Question

How to update column value after some time interval

I need to update a particular column value from Y to N after every 3 minutes.

Table Structure

`u_id` int(11) NOT NULL,
`status` varchar(11) NOT NULL


How can i change status N after 3 mins for each row in phpmyadmin

Answer

It seems like you are looking for something called EVENTS in MySQL.

You may try following steps to achieve.

SET GLOBAL event_scheduler = ON; -- enable event scheduler.
SELECT @@event_scheduler;  -- check whether event scheduler is ON/OFF
CREATE EVENT e_store_ts  -- create your event
    ON SCHEDULE
      EVERY 180 SECOND  -- run every 180 secs (3 Min)
    DO
      UPDATE myschema.youtable set mycolumn='N' -- update this table

To see the events that created

 SHOW EVENTS;

You may visit this link as well.

Comments