I have an MySQL table with 25000 rows.
This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything.
However, sinc
You can use the "ORDER BY DESC" option, then put it back in the original order:
(SELECT * FROM tablename ORDER BY id DESC LIMIT 10) ORDER BY id;
A low-tech approach: Doing this with SQL might be overkill. According to your question you just need to do a one-time verification of the import.
Why not just do: SELECT * FROM ImportTable
and then scroll to the bottom of the results grid and visually verify the "last" few lines.
All the answers here are better, but just in case... There is a way of getting 10 last added records. (thou this is quite unreliable :) ) still you can do something like
SELECT * FROM table LIMIT 10 OFFSET N-10
N - should be the total amount of rows in the table (SELECT count(*) FROM table). You can put it in a single query using prepared queries but I'll not get into that.
Select from the table, use the ORDER BY __ DESC to sort in reverse order, then limit your results to 10.
SELECT * FROM big_table ORDER BY A DESC LIMIT 10
you can with code select 10 row from end of table. select * from (SELECT * FROM table1 order by id desc LIMIT 10) as table2 order by id"
If you have not tried the following command
SELECT TOP 10 * FROM big_table ORDER BY id DESC;
I see it's working when I execute the command
SELECT TOP 10 * FROM Customers ORDER BY CustomerId DESC;
in the Try it yourself command window of https://www.w3schools.com/sql/sql_func_last.asp