My site is a school web site.
The teacher choose every day a random student from the ‘students’ table, and update it in ‘randoms’ table.
Now I’m trying something else for making it easier.
I want the table ‘randoms’ will be updated every hour without the teacher, automatically.
it means that every hour, random student from the ‘students’ table will be updated in the ‘randoms’ table.
Is someone know how to do that?
thanks so much!!
2
Answers
If you have access to the host you can use
cron
to program a query which makes the task (assuming you are on linux). The query should be something like:And you can create the cron task issuing in the console
crontab -e
and adding a line like this:This will execute your query every hour. If you prefer executing it every 2 hours or more, just replace
*/1
for the desired period of time. If you are on Windows you can also run the sql using the Task Scheduler.This is how it is done in mysql.
There is some further information to enable disable the event scheduler in the mysql docs if you are having any issues with that working https://dev.mysql.com/doc/refman/5.7/en/events-configuration.html