Hello.


In the manual we have:



" Returns the first automatically generated value that was set for an

AUTO_INCREMENT column by the last INSERT or UPDATE query to affect such

a column."



So in you query both last_insert_id() should return the same value,

which equals to the value that was set for an AUTO_INCREMENT column by

the last INSERT or UPDATE query. Note that you have one query, which

just inserts several rows, so during it is processed the returned value

of last_insert_id() is constant, even if your bulk insert is changing an

AUTO_INCREMENT field.











Björn Persson wrote:



> 

> 

> Speaking of LAST_INSERT_ID(), does anyone know how MySQL is supposed to=20

> process a statement like this:?

> 

> insert into some_table (ref_field, other_field)

> values (last_insert_ID(), 1), (last_insert_ID(), 2);

> 

> I've looked in the manual for details on which order that statement is=20

> processed in, but I haven't found an answer.

> 

> Bj=C3=B6rn Persson

> 



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to