How do I get the last line ID in the database?

advertisements

How to receive the last row id in the database without generating a new row or updating the row.

Just to read the last id?

I have the function mysql_insert_id and need something like this, but without generating a new row.


SELECT MAX(id) AS latest_id
FROM table_name

If you instead want the comming (and not yet existing) id without inserting a row, see my previous answer.