In my database have 100 records but i want only first 10 records in descending order not for whole database in descending order.
Ex: Database:Records
1,2,3,4,5,6,,7,8,9,10,11,12....................100.
First 10 Records:
10,9,8,7,6,5,4,3,2,1
Use LIMIT. See the mySQL manual on SELECT
For example:
SELECT id FROM tablename ORDER BY ID LIMIT 0,10
the turning around of the results like you show is then probably best done in PHP using array_reverse(), I can't think of a easy mySQL way to do this.
If I understand your question correctly,
SELECT x FROM (SELECT x FROM table ORDER BY x ASC LIMIT 10) ORDER BY x DESC
The SELECT in parentheses selects the first 10 records (by ascending x) and the outer SELECT sorts them in the order you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With