List:Bugs« Previous MessageNext Message »
From:Luc Van der Veken Date:April 23 2001 7:24am
Subject:LAST_INSERT_ID returning wrong value after multiple row insert in a single query
View as plain text  
# 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).

Thread
LAST_INSERT_ID returning wrong value after multiple row insert in a single queryLuc Van der Veken23 Apr
  • 4 GB table size problem [NO BUG REPORT]Wolfgang Hurst23 Apr
    • Re: 4 GB table size problem [NO BUG REPORT]Sinisa Milivojevic23 Apr
  • Re: LAST_INSERT_ID returning wrong value after multiple row insert in a single querySinisa Milivojevic23 Apr
  • LAST_INSERT_ID returning wrong value after multiple row insert in a single queryMichael Widenius23 Apr