SELECT MAX(id) FROM tablename;
mysql> select *from LastInsertedRow where Id=(SELECT LAST_INSERT_ID());
SELECT MAX(id) AS last_id FROM users
-- last_id --
-- 33 --
-- To get the last inserted auto-increment row ID: --
SELECT LAST_INSERT_ID( optional_expression )
-- If you have just inserted it using a command in C# use: --
int lastId = (Int32)yourCommand.LastInsertedId;
//You need to use this in OpenCart for getting last insert id:
$this->db->getLastId()