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 > SELECT all records that occurred in the last five minutes or less
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
SELECT all records that occurred in the last five minutes or less

Réponse
 
LinkBack Outils de la discussion
Vieux 29/09/2007, 23h04   #1
andrecal
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut SELECT all records that occurred in the last five minutes or less

I have a table with a TIMESTAMP entry, and I would like to find a
query that will look at this table and only return results that shows
the TIMESTAMP to be five minutes ago or less.

Something along these lines:
SELECT * FROM table_name WHERE entry_date BETWEEN NOW() AND NOW()-5
minutes ago

entry_date is a full timestamp

any appreciated,
AN

  Réponse avec citation
Vieux 29/09/2007, 23h22   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SELECT all records that occurred in the last five minutes or less

andrecal wrote:
> I have a table with a TIMESTAMP entry, and I would like to find a
> query that will look at this table and only return results that shows
> the TIMESTAMP to be five minutes ago or less.
>
> Something along these lines:
> SELECT * FROM table_name WHERE entry_date BETWEEN NOW() AND NOW()-5
> minutes ago
>
> entry_date is a full timestamp
>
> any appreciated,
> AN


Hmm, you say "any appreciated", yet you have completely ignored the
superb given by the developers when they wrote the section "Date and
Time Functions" in the MySQL user manual
(http://dev.mysql.com/doc/refman/5.0/...functions.html)!

I just went there to find the answer.

SELECT
*
FROM table_name
WHERE entry_date > date_sub( now( ) , INTERVAL 5 MINUTE )

or you may prefer:

SELECT
*
FROM table_name
WHERE entry_date > now( ) - INTERVAL 5 MINUTE


  Réponse avec citation
Vieux 29/09/2007, 23h30   #3
andrecal
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SELECT all records that occurred in the last five minutes or less

Thanks Paul, that really ed. I think I wasn't using the right
keywords when I did search mysql.com and google.com.
Thanks again,
AN


  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 17h12.


É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,10189 seconds with 11 queries