reversing the order of a limited query

This is a discussion on reversing the order of a limited query within the MySQL Database forums, part of the Database Forums category; I keep track of some documents for work, and have built an rss feed to show the most recent 20. ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008
camills@mit.edu
 
Posts: n/a
Default 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
Reply With Quote
  #2 (permalink)  
Old 04-17-2008
Captain Paralytic
 
Posts: n/a
Default 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
Reply With Quote
  #3 (permalink)  
Old 04-20-2008
Tigger
 
Posts: n/a
Default 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


Reply With Quote
  #4 (permalink)  
Old 04-22-2008
camills@mit.edu
 
Posts: n/a
Default 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.
Reply With Quote
  #5 (permalink)  
Old 04-23-2008
Captain Paralytic
 
Posts: n/a
Default 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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:17 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0