3 messages in com.mysql.lists.win32LAST_INSERT_ID returning wrong value ...
FromSent OnAttachments
Luc Van der Veken23 Apr 2001 00:24 
Sinisa Milivojevic23 Apr 2001 04:26 
Michael Widenius23 Apr 2001 06:46 
Subject:LAST_INSERT_ID returning wrong value after multiple row insert in a single query
From:Luc Van der Veken (luc@wimi.be)
Date:04/23/2001 12:24:05 AM
List:com.mysql.lists.win32

# This occurs in MySQL 3.23.36, win32 version. # I haven't seen anything about it in the 3.23.37 change list, # nor have I seen a report of it in the win32 list # or in the bug tracker on sourceforge. # # Statements to reproduce (you can use this message as script):

# drop table if exists test9; create table test9 (i1 int auto_increment primary key, i2 int); insert into test9 (i2) values (11),(12),(13); select last_insert_id(); insert into test9 (i2) values (14),(15),(16); select * from test9; select last_insert_id();

# The last_insert_id() function returns the value corresponding # to the _first_ inserted row for each INSERT query, # instead of the last (i.e. values 1 and 4 instead of 3 and 6 # here, respectively).