Bug #35089 LAST_INSERT_ID returns 0 on using INSERT... ON DUPLICATE KEY UPDATE ...
| Submitted: | 5 Mar 2008 19:55 | Modified: | 5 Mar 2008 21:48 |
|---|---|---|---|
| Reporter: | Greg Smyth | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.1.22-rc-community-log | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | insert, LAST_INSERT_ID, ON DUPLICATE KEY, regression | ||
[5 Mar 2008 19:55]
Greg Smyth
[5 Mar 2008 21:48]
Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php According to http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_last-insert-id: "For MySQL 5.1.12 and later, LAST_INSERT_ID() (no arguments) returns the first *automatically* generated value successfully inserted for an AUTO_INCREMENT column as a result of the most recently executed INSERT statement." In your case value inserted not automatically, but explicitly. Same behavior for regular INSERT: create table blah (a int, PRIMARY KEY(a)); insert into blah values (1),(2),(3),(4),(5),(6),(7); select last_insert_id(); last_insert_id() 0
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.