I want to get last five records from the table using LIMIT in MySQL but also I am in need to get those records in ascending order. I do the following:
SELECT emp_id, emp_name FROM employ ORDER BY emp_id DESC LIMIT 5;
Obviously, the result will be like below:
Actually, I want the results in ascending order like below:
Is there any solution to get the results in ascending order?
To get last top records using LIMIT in MySQL also in ascending order is possible. You may amend your above query as below. The trick will serve your purpose:
(SELECT emp_id, emp_name FROM employ ORDER BY employ_id DESC LIMIT 5)
ORDER BY emp_id ASC;