Skip to content

mysql_insert_id

Georg Richter edited this page Jun 11, 2021 · 1 revision

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() and connected by mysql_real_connect().

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

Clone this wiki locally