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 > reversing the order of a limited query
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
reversing the order of a limited query

Réponse
 
LinkBack Outils de la discussion
Vieux 17/04/2008, 00h21   #1
camills@mit.edu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut reversing the order of a limited query

I keep track of some documents for work, and have built an rss feed to
show the most recent 20. A simplified version of the query is here:

SELECT date_created, id, name
FROM documents
ORDER BY date_created desc
LIMIT 0, 20

This will show the most recent documents, with the most recent on the
top. Is it possible to reverse the order of these last twenty?

I'd like to have a list of the most recent documents, ordered ascending.

Thanks,
Charley
  Réponse avec citation
Vieux 17/04/2008, 10h10   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: reversing the order of a limited query

On 17 Apr, 00:21, cami...@mit.edu wrote:
> I keep track of some documents for work, and have built an rss feed to
> show the most recent 20. A simplified version of the query is here:
>
> SELECT date_created, id, name
> FROM documents
> ORDER BY date_created desc
> LIMIT 0, 20
>
> This will show the most recent documents, with the most recent on the
> top. Is it possible to reverse the order of these last twenty?
>
> I'd like to have a list of the most recent documents, ordered ascending.
>
> Thanks,
> Charley


Here is one way:
SELECT * FROM (
SELECT date_created, id, name
FROM documents
ORDER BY date_created desc
LIMIT 0, 20 ) AS md
ORDER BY date_created
  Réponse avec citation
Vieux 20/04/2008, 14h30   #3
Tigger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: reversing the order of a limited query

"Captain Paralytic" <paul_lautman@yahoo.com> wrote in message
news:989c7cc7-9b6e-4912-958e-dfbd7ff524ee@y21g2000hsf.googlegroups.com...
> On 17 Apr, 00:21, cami...@mit.edu wrote:
>> I keep track of some documents for work, and have built an rss feed to
>> show the most recent 20. A simplified version of the query is here:
>>
>> SELECT date_created, id, name
>> FROM documents
>> ORDER BY date_created desc
>> LIMIT 0, 20
>>
>> This will show the most recent documents, with the most recent on the
>> top. Is it possible to reverse the order of these last twenty?
>>
>> I'd like to have a list of the most recent documents, ordered ascending.
>>
>> Thanks,
>> Charley

>
> Here is one way:
> SELECT * FROM (
> SELECT date_created, id, name
> FROM documents
> ORDER BY date_created desc
> LIMIT 0, 20 ) AS md
> ORDER BY date_created


How do you read the data?

If its stored in a collection, would it be easy to reverse the order you
iterate it?

--
Tony
http://www.mccreath.org.uk


  Réponse avec citation
Vieux 22/04/2008, 19h25   #4
camills@mit.edu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: reversing the order of a limited query

Tigger wrote:
> "Captain Paralytic" <paul_lautman@yahoo.com> wrote in message
> news:989c7cc7-9b6e-4912-958e-dfbd7ff524ee@y21g2000hsf.googlegroups.com...
>> On 17 Apr, 00:21, cami...@mit.edu wrote:
>>> I keep track of some documents for work, and have built an rss feed to
>>> show the most recent 20. A simplified version of the query is here:
>>>
>>> SELECT date_created, id, name
>>> FROM documents
>>> ORDER BY date_created desc
>>> LIMIT 0, 20
>>>
>>> This will show the most recent documents, with the most recent on the
>>> top. Is it possible to reverse the order of these last twenty?
>>>
>>> I'd like to have a list of the most recent documents, ordered ascending.
>>>
>>> Thanks,
>>> Charley

>> Here is one way:
>> SELECT * FROM (
>> SELECT date_created, id, name
>> FROM documents
>> ORDER BY date_created desc
>> LIMIT 0, 20 ) AS md
>> ORDER BY date_created

>
> How do you read the data?
>
> If its stored in a collection, would it be easy to reverse the order you
> iterate it?
>


I'm spitting it out with php - the nested selects are probably the
easiest, but I've thought about reversing it after i grab it from mysql,
too.
  Réponse avec citation
Vieux 23/04/2008, 11h09   #5
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: reversing the order of a limited query

On 20 Apr, 13:30, "Tigger" <mccre...@bigfoot.com> wrote:
> "Captain Paralytic" <paul_laut...@yahoo.com> wrote in message
>
> news:989c7cc7-9b6e-4912-958e-dfbd7ff524ee@y21g2000hsf.googlegroups.com...
>
>
>
> > On 17 Apr, 00:21, cami...@mit.edu wrote:
> >> I keep track of some documents for work, and have built an rss feed to
> >> show the most recent 20. A simplified version of the query is here:

>
> >> SELECT date_created, id, name
> >> FROM documents
> >> ORDER BY date_created desc
> >> LIMIT 0, 20

>
> >> This will show the most recent documents, with the most recent on the
> >> top. Is it possible to reverse the order of these last twenty?

>
> >> I'd like to have a list of the most recent documents, ordered ascending.

>
> >> Thanks,
> >> Charley

>
> > Here is one way:
> > SELECT * FROM (
> > SELECT date_created, id, name
> > FROM documents
> > ORDER BY date_created desc
> > LIMIT 0, 20 ) AS md
> > ORDER BY date_created

>
> How do you read the data?


I don't read it. I did not post the question.
  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 22h40.


É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,12502 seconds with 13 queries