|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
>From PHP I can do this programatically, but I wonder if there is an
easier way to do it. I need to keep a log of the prior 10 transactions, user id and summary. I order them by timestamp and can retrieve the 10 highest in reverse order easily, But, to keep the list from growing unnecessarily, is there an easy way to delete all the log items other than the highest (by timestamp) 10 ? bill |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
bill wrote: > >From PHP I can do this programatically, but I wonder if there is an > easier way to do it. > I need to keep a log of the prior 10 transactions, user id and > summary. > I order them by timestamp and can retrieve the 10 highest in reverse > order easily, > But, to keep the list from growing unnecessarily, is there an easy way > to delete all the log items other than the highest (by timestamp) 10 ? > > bill I'd do it in two steps. CREATE TABLE my_new_table AS SELECT * FROM my_old_table ORDER BY timestamp DESC LIMIT 10 and then, when happy with the results - and certain that I want to do this... DROP my_old_table |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Sat, 03 Nov 2007 04:27:47 -0700, bill wrote:
>>From PHP I can do this programatically, but I wonder if there is an > easier way to do it. > I need to keep a log of the prior 10 transactions, user id and > summary. > I order them by timestamp and can retrieve the 10 highest in reverse > order easily, > But, to keep the list from growing unnecessarily, is there an easy way > to delete all the log items other than the highest (by timestamp) 10 ? > > bill something like: DELETE from FROM list ORDER BY timestamp DESC LIMIT 10,4321 will delete from the list 4321 records starting at the eleventh row -- Yhhx |
|
![]() |
| Outils de la discussion | |
|
|