Forum Moderators: open

Message Too Old, No Replies

Pruning Old Fields

How to automatically delete old database entries in MySQL

         

sawatkins

6:15 pm on Apr 20, 2007 (gmt 0)

10+ Year Member



How does one go about deleting certain entries once they're old or unused?

Is there a simple way in MySQL, or do I have to make my users delete them automatically.

Ideally, I'd like to allow users to discard their old messages right away AND delete any messages that are older than, say, 30 days.

Any advice?

</g>

souFrag

7:59 am on Apr 22, 2007 (gmt 0)

10+ Year Member



You must add a timestamp to each row and run something like "DELETE FROM table WHERE post_date > SOME_FUNCTION(NOW())"..

..where SOME_FUNCTION is some of the date functions built in with MySQL (i do not know them exactly.. but you may look for them at the mysql website :-)).