I want to select the last 3 rows of an sql table. I know I should use SELECT * FROM table ORDER BY DESC LIMIT 3, but the problem with this code is that it selects the rows from the end. For example, it selects 30, then 29, then 28. But, I need them in this format: 28, 29, 30. Any suggestion?
Try this:
SELECT * FROM (
SELECT * FROM reset ORDER BY id DESC LIMIT 3
) as r ORDER BY id
I hope this help your problem
select * from
(
select * from reset
order by id DESC LIMIT 3
) t
order by id ASC
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