how do I show last 5 rows of my table, MySQL, ordered by ID . For example , I have a table with 15 records. I want to get the ID 10 , 11, 12 , 13, 14 and 15. In that order. Low to High .
SELECT * FROM temperaturas ORDER BY id DESC LIMIT 5;
This way I get ID 15 , 14, 13, 12 , 11 and 10. They are the last , but ordered backwards .
It's doable by selecting the last 5 rows as you've done it in an inner SELECT, and then reordering it in outer SELECT, i.e.:
SELECT *
FROM (SELECT * FROM temperaturas ORDER BY id DESC LIMIT 5)
ORDER BY id;
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