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;

Octavian

----- Original Message ----- From: "Rich" <[EMAIL PROTECTED]>
To: "Submit MySQL" <mysql@lists.mysql.com>
Sent: Saturday, June 30, 2007 3:45 PM
Subject: Select Last X rows


Hi folks.

Just wanting to know the best way to grab the last 10 rows from a table. Looking twice to the db to see how many records there are will be outdated by the time the SELECT is done, so it's moot. This is a fast moving db with records coming and going.

Instead of having an offset in LIMIT, is there a way to ask for the last 10 rows directly?

Cheers


Rich in Toronto



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to