I have a table called “teams” with column “inactive” and another table “events” with column “time”. How can I have the “inactive” column updated (to true), if the latest date in “events” for any team occurred X amount of time ago?
I know this can be doe with a php script, but i’m looking for a sql solution
In MySQL 5.1 you have EVENTs …basically this is like a cron job, but inside the database:
http://dev.mysql.com/doc/refman/5.1/en/events.html
You can set one up and let it run, well, as often as you need to do the update.
something like:
You may need t configure the server to enable events:
http://dev.mysql.com/doc/refman/5.1/en/events-configuration.html
Unfortunately, you need the SUPER privilege to enable it:
http://dev.mysql.com/doc/refman/5.1/en/events-privileges.html