Hi All,
Just wondering if anyone can help me work out if it's possible to write
a query that deletes all but the (n) most recent records in a table,
using a timestamp field to determine record order?
For the sake of the argument, let's say I have a table that currently
has 500 records in it and I want to retain the most recent 200 records,
therefore deleting the oldest 300 records (though, I only know ahead of
time that I want to keep the most recent (n) records, i.e. 200 in this
example, I don't know how many records there are in the table and at
times there may actually be less that 200 records, meaning all records
should remain).
Is this possible using just SQL, or do I need to do some of the work in
PHP?
Any help appreciated!
Warm regards,
Murray Wells
http://www.planetthoughtful.org
Mysql, query, sql