List:General Discussion« Previous MessageNext Message »
From:Jim Faucette Date:June 2 1999 9:39pm
Subject:Re: mysql_insert_id()
View as plain text  
Matthias Pigulla wrote:
>     mysql_query(&con, "insert into a (val) values('test')");
>     printf("last insert id is %d\n", mysql_insert_id(&con));
>     mysql_query(&con, "insert into b (id,val)
> values(last_insert_id(),'test')");
>     printf("last insert id is %d\n", mysql_insert_id(&con));
> 

The manual is vague on this point. 
"It will not even be changed if you update another `AUTO_INCREMENT'
column with a non-magic value (that is, a value that is not `NULL' and
not 0)."

Unfortunately the manual is mute on what should happen to LAST_INSERT_ID
after an INSERT into a NON-AUTO_INCREMENT field. If you want to use the
original value to update or insert into more than one table, you
probably should retain it yourself rather than rely on MySQL.

  jim...
Thread
mysql_insert_id()Matthias Pigulla1 Jun
  • Re: mysql_insert_id()Paul DuBois1 Jun
    • Re: mysql_insert_id()Matthias Pigulla3 Jun
      • Re: mysql_insert_id()Paul DuBois3 Jun
    • Re: mysql_insert_id()Jim Faucette3 Jun
    • Re: mysql_insert_id()Matthias Pigulla3 Jun
      • Re: mysql_insert_id()Benjamin Pflugmann3 Jun
        • Re: mysql_insert_id()Michael Widenius3 Jun
          • Re: mysql_insert_id()Paul DuBois3 Jun
    • Re: mysql_insert_id()Matthias Pigulla3 Jun
    • Re: mysql_insert_id()Matthias Pigulla3 Jun
      • Re: mysql_insert_id()Michael Widenius3 Jun