Hi i'm trying to write a simple SQL command to use within PHP.

I want to select the whole table, sort by one of the columns, then only display the top 100 rows.

Without the WHERE rownum <=10 it works fine. But it displays the whole contents of the table rather than the top 10 from the quantity column.


You need to use LIMIT

$sql = 'SELECT * FROM Possesions ORDER BY quantity DESC LIMIT 0,10';

I think this is helpful for you

select * from employee order by book_id  limit 7;