MySQL Forums
Forum List  »  Newbie

i need a help about LIMIT
Posted by: mantz
Date: June 14, 2005 09:49PM

i have 10 rows in a table
i want to select the last 3 rows only
i tried: "select * from table1 order by id desc limit 0,3" it selected rows 10, 9 & 8 but i want it ordered like 8, 9 & 10, what should i do??
i also tried: "select * from table1 order by id asc limit 0,3" but it only selects the first 3 rows

it worked when i used subselect:
select * from (select * from table1 order by id desc limit 0,3) as test order by test.id asc
but my host is using mysql 3.23, which does not accept subselecting..

i also tried: "select * from table1 order by id asc limit count(*)-2,3" but it only gave me an error msg
i even tried: "select * from table1 order by id asc limit 3,-1" but same: error

any help is appreciated, thanks very much

Options: ReplyQuote


Subject
Written By
Posted
i need a help about LIMIT
June 14, 2005 09:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.