Skip to content
Advertisement

Update every 5 minutes a value

I am using a MySql DataBase and I want to know if there are any methods to modify a value of a column every x minutes/hours/days.

For example, I want to execute the following query every 5 minutes, UPDATE table SET x=0;.

Could I set an event or something like this from the PHPMyAdmin interface?

Advertisement

Answer

I’m not aware about how to use PHPMyAdmin interface to create events, however, this can be done in “pure” SQL :

About the part ON SCHEDULE EVERY 5 MINUTE, this will execute the event now, and then every 5 minutes, forever.

If you want to delay the execution, you can add STARTS after the EVERY statement :

You can define when the EVENT should stop working using ENDS :

Of course, you can combine both STARTS and ENDS

If you have more than 1 query to perform in the event, you need to wrap the instructions inside BEGIN / END :

For more informations, check the documentation

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement