PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Easier way to delete if count over 10
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Easier way to delete if count over 10

Réponse
 
LinkBack Outils de la discussion
Vieux 03/11/2007, 12h27   #1
bill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Easier way to delete if count over 10

>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

  Réponse avec citation
Vieux 03/11/2007, 14h28   #2
strawberry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easier way to delete if count over 10


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

  Réponse avec citation
Vieux 03/11/2007, 18h39   #3
Luuk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Easier way to delete if count over 10

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h57.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10395 seconds with 11 queries