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
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
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
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;
}
This works:
select * from db.table A, db.table B WHERE A.id=B.id order by B.id,A.id desc
limit 10;
regards
rene
- Original Message -
From: "Remco van den Berg" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 31, 2001 3:15 PM
Subject: Re: How to select the 10 last
SELECT * FROM item
ORDER BY ID
LIMIT 10
or change to "ORDER BY ID DESC" to get the desired result.
- Scott
May be it could work
SELECT * FROM item ORDER BY ID LIMIT count(*)-10,10
or
SELECT * FROM SELECT * FROM item ORDER BY ID DESC LIMIT 10 ORDER BY ID
On Wed, Jan 31, 2001 at 02:02:05AM +0300, Rus wrote:
He need 10 last records ordered by id.
You also can try this
SELECT *,count(*) as c FROM item GROUP BY ID LIMIT c-10,10
mysql select *,count(*) as c from lid group by id limit c-10,10;
ERROR 1064: You have an error in your SQL syntax