SELECT max(id) FROM tableName SELECT id FROM table name ORDER BY id DESC LIMIT 1 SELECT LAST_INSERT_ID() from tablename // In PHP object-oriented calls $last_id = $conn->insert_id; The last will work if you have only one autoincrement field.