Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Select Last X rows

From: Andrew Hutchings <info(at)a-wing.co.uk>
Date: Sat Jun 30 2007 - 12:19:36 EDT


Rich wrote:
> Ah that makes sense. It's a double shot, first grabbing the necessary
> records, then selecting all in that temp value (hitlist) in reverse order.
>
> Well done.
>
> Cheers
>
> On Jun 30, 2007, at 11:26 AM, Octavian Rasnita wrote:
>

>> Hi,
>>
>> Try something like this:
>>
>> select * from (select * from table_name where ... order by last_update 
>> desc limit 10) as tbl order by tbl.last_update;

>
>
>
> Rich in Toronto
>
>

I guess you could do:

select * from table WHERE id > ((SELECT MAX(id) from table) - 10);

Its not perfect, but it executes pretty fast for me.

-- 
Andrew Hutchings - LinuxJedi - 
http://www.linuxjedi.co.uk/
Windows is the path to the darkside...Windows leads to Blue Screen. Blue 
Screen leads to downtime. Downtime leads to suffering...I sense much 
Windows in you...

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Sat Jun 30 12:20:31 2007

This archive was generated by hypermail 2.1.8 : Sat Jun 30 2007 - 12:30:02 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library