Page 1 of 1

sorting limit

Posted: Sun Jul 21, 2002 6:46 am
by Z3r0Tol3ranc3
hi, i'm coding a news page with a full newspage and an other page that only show the last 3 items, my question, HOW? i can't get it sorted right because i simply dont know how, this is the query call:

Code: Select all

$query="SELECT * FROM nieuwtjes ORDER BY id DESC LIMIT 0 , 100";
what should i add to it that only the 3 last news items are shown? MAX 3 doesn't work :)

Posted: Sun Jul 21, 2002 7:19 am
by twigletmac
You don't say what you want it ordered by, currently it is being ordered by id, which is what the

Code: Select all

ORDER BY id DESC
bit is - order by id in descending order.

Code: Select all

LIMIT 0, 100
Describes how many items should be returned. To get the first three results:

Code: Select all

LIMIT 3
Have a look at the mysql documentation on SELECT to find out more:
http://www.mysql.com/doc/S/E/SELECT.html

Mac

Posted: Sun Jul 21, 2002 7:31 am
by Z3r0Tol3ranc3
ok thx dude, that helped me out,
thx again