Name
mysql_insert_id( )
Synopsis
my_ulonglong mysql_insert_id(MYSQL *mysql)
This returns the identification number
issued to the primary key of the last record inserted using
INSERT
in MySQL for the current connection. This
works provided the column utilizes AUTO_INCREMENT
and the value was not manually set. Otherwise, 0 is returned.
... const char *sql_stmnt = "INSERT INTO workreq (req_date, client_id, description) VALUES(NOW( ), '1000', 'Net Problem')"; mysql_query(mysql, sql_stmnt); my_ulonglong wr_id = mysql_insert_id(mysql); printf("Work Request ID: %ld \n", wr_id); ...
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.