mysql_insert_id(3)

  Name
mysql_insert_id - returns the auto generated ID used in last statement

  Synopsis

        #include <mysql.h>
        my_ulonglong mysql_insert_id(MYSQL * mysql);

  Description
Returns the auto generated ID generated by a SQL statement (usually INSERT) on a table for a column defined with AUTO_INCREMENT attribute.

  Parameters:
mysql is a connection identifier, which was previously allocated by mysql_init(3) and connected by mysql_real_connect(3).

Return value
Returns the value of the modified column with AUTO_INCREMENT attribute. If the table doesn’t contain an auto_increment column or no INSERT/UPDATE statement was executed, this function will return zero.

  See also

•   mysql_query(3)