Get the ID of the last inserted row --last_insert_id function

Use the last_insert_id function to get the ID of the last inserted row.

select last_insert_id ();

If you have inserted user data and want to know its ID, use the last_insert_id function.

If auto_increment is specified for a column, MariaDB manages it as an integer. It is incremented when a row is inserted. You can get the incremented value.

Rest assured that other clients are in parallel and are inserting rows at the same time. You can get the correct ID without being aware of the transaction.

Associated Information