I have a mysql query
SELECT * FROM lead LIMIT 5 OFFSET 0
to select data from the table lead and limit the results to 5 with offset of 0. I would like to order the results by its id by desc, so the results will be populated as the last added data first.
I tried
SELECT * FROM lead LIMIT 5 OFFSET 0 order by id desc
but it’s not working. Please correct me where am wrong.
You have to
The manual ( http://dev.mysql.com/doc/refman/5.0/en/select.html ) describes that LIMIT is only allowed to appear after the ORDER BY.