Try sorting in DESCending order.

SELECT * FROM item ORDER BY id DESC LIMIT 10;

-Tilghman

-- 
"There cannot be a crisis today.  My schedule is already full."
     --Henry Kissinger

> -----Original Message-----
> From: Remco van den Berg [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 30, 2001 17:29
> 
> On Tue, Jan 30, 2001 at 11:48:22PM +0300, Rus wrote:
> > May be it could work
> > SELECT  * FROM item ORDER BY ID LIMIT count(*)-10,10
> 
> mysql> SELECT  id FROM lid ORDER BY ID LIMIT count(*)-10,10;
> ERROR 1064: You have an error in your SQL syntax near 
> 'count(*)-10,10' at line 1
> 
> > or
> > SELECT  * FROM SELECT  * FROM item ORDER BY ID DESC LIMIT 
> 10 ORDER BY ID
> 
> mysql> select * from select * from lid order by id DESC limit 
> 10 order by id;
> ERROR 1064: You have an error in your SQL syntax near 'select 
> * from lid order by id DESC limit 10 order by id' at line 1
> 
> 
> I think you have to make use of at least two queries. One to 
> get MAX(id) and
> one for the actual query:
> 
> mysql> select MAX(id) from lid;
> +---------+
> | MAX(id) |
> +---------+
> |     489 |
> +---------+
> 1 row in set (0.00 sec)
> mysql> select id from lid order by id limit 479,10;
> 
> But that only works when all id's up to the last one exist.
> If you delete records from the table calculating 479 by 
> substracting 10 
> from MAX(id) doesn't work.
> 
> So, the only solution left, I can think of, is to make use of 
> an temporary
> table (in memory) to store the results of your query which 
> are in the wrong
> order. And then query the temporary table to get right order.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to