Jump to content

Getting the most recent X entries, but shown in reverse order


mb81

Recommended Posts

Hello all,

 

I have a query where I need to get the 10 most recently added lines in a particular MySQL table, but I need to process them starting at the oldest of the 10.

 

Is there a way to reverse the order it returns the rows if I am using a datetime field in DESC order to sort them?

 

I thought about running the whole query, getting the number of rows, and then doing another query to limit to the last 10.

 

I also thought about running the query, then seeking to the 10th to the last row and going from there.

 

Are there any other suggestions or some magic syntax I am missing?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.