每小时删除旧的MySQL记录

Suppose I include the built in MySQL timestamp into my fields on my database table.

Everytime I update the records it will update the timestamp.

I would like to delete records than are older than an hour. Any ideas for how best to do this?

I could have a loop checking the timestamp for all records or perhaps a trigger in the database?

You can use a cronjob to schedule a query to be executed in a fixed time interval:

DELETE FROM table_name WHERE time_created < (UNIX_TIMESTAMP() - 3600);

Every time it's run, it will delete all records older than 1 hour (which is presumably what you want).