I am using the command
SELECT * FROM table LIMIT 0, 10
to retrieve the firs 10 rows of the table.
Is there a way to do the same thing but with the last 10 rows?
Thanks in advance.
I am using the command
SELECT * FROM table LIMIT 0, 10
to retrieve the firs 10 rows of the table.
Is there a way to do the same thing but with the last 10 rows?
Thanks in advance.
SQL tables represent unordered sets. Your query gets 10 arbitrary rows, which are generally the first 10 rows inserted into the table. But, you should not depend on this ad-hoc functionality.
If you have an auto-incremented id, then you get the first ten rows by doing:
select t.*
from t
order by id
limit 10;
To get the last ten rows, use order by id desc
.