PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Select question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Select question

Réponse
 
LinkBack Outils de la discussion
Vieux 25/10/2007, 11h55   #1
Matthew Stuart
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Select question

I've got this statement to select the last two entries in my db:

SELECT top 2 *
FROM Content
ORDER BY ContentID desc

and it works fine because it selects the last two items entered into
the db. However, I only want to be able to select item 2 rather than
both 1 and 2. How do I do that?

Thanks

Mat



  Réponse avec citation
Vieux 25/10/2007, 13h55   #2
Ralf Hüsing
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Select question

Matthew Stuart schrieb:

> I've got this statement to select the last two entries in my db:
>
> SELECT top 2 *
> FROM Content
> ORDER BY ContentID desc
>
> and it works fine because it selects the last two items entered into

the db. However, I only want to be able to select item 2 rather than
both 1 and 2. How do I do that?

Hi Mat,

"TOP 2" is not MySQL?

However, MySQL knows LIMIT [1] which is more powerful, try:

SELECT *
FROM Content
ORDER BY ContentID DESC
LIMIT 1,1

regards
-Ralf

[1]: http://dev.mysql.com/doc/refman/5.0/en/select.html

  Réponse avec citation
Vieux 25/10/2007, 15h00   #3
Jerry Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Select question



Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com

> -----Original Message-----
> From: Matthew Stuart [mailto:mrs@btinternet.com]
> Sent: Thursday, October 25, 2007 6:55 AM
> To: MySQL email support
> Subject: Select question
>
> I've got this statement to select the last two entries in my db:
>
> SELECT top 2 *
> FROM Content
> ORDER BY ContentID desc
>
> and it works fine because it selects the last two items entered into
> the db. However, I only want to be able to select item 2 rather than
> both 1 and 2. How do I do that?
>
> Thanks
>
> Mat
>


[JS] What does adding LIMIT 2,1 do? I'm not sure what "SELECT top 2 *"
means.

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com




  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 07h18.


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