I think the only way to do it is first get the amount of items:

   SELECT COUNT(*) FROM item;

if you use PHP, store the count in a variable called $count.
subtract 10 from count:

$limit = 10;
if($count < $limit) {
  $limit = $count;
}
$count = $count - 10;
if($count < 0) {
  $count = 0;
}

then do the following:

   SELECT * FROM item ORDER BY id LIMIT $count,$limit;


Tim Samshuijzen



At 09:03 31-1-2001 -0600, you wrote:
>Remco van den Berg wrote:
>> 
>> On Wed, Jan 31, 2001 at 08:00:23AM -0600, The Tilghman wrote:
>> > Try sorting in DESCending order.
>> >
>> > SELECT * FROM item ORDER BY id DESC LIMIT 10;
>> >
>> > -Tilghman
>> 
>> People,
>> 
>> Thanks for all the answers, but the question was:
>> 
>>   "How to get the last 10 items in incrementing order."
>> 
>> Please read thread before answering.
>> 
>> -Remco
>>
>I've been reading the thread.
>You were told how to get the last 10 records.
>That is the only way  to get them.
>Unfortunately, that means they will be in reverse order.
>You must be reading them into an array somewhere, so you
>can easily access them in either order once you have stored them.
>
>---------------------------------------------------------------------
>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
>
>
>


---------------------------------------------------------------------
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