How can I SELECT the last row in a MySQL table?
SELECT
I'm INSERTing data and I need to retrieve a column value from the previous row.
INSERT
There's an auto_increment in the table.
auto_increment
Yes, there's an auto_increment in there
If you want the last of all the rows in the table, then this is finally the time where MAX(id) is the right answer! Kind of:
MAX(id)
SELECT fields FROM table ORDER BY id DESC LIMIT 1;
1.4m articles
1.4m replys
5 comments
57.0k users