How can I SELECT
the last row in a MySQL table?
I'm INSERT
ing data and I need to retrieve a column value from the previous row.
There's an auto_increment
in the table.
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:
SELECT fields FROM table ORDER BY id DESC LIMIT 1;