>On Sun, 7 Apr 2002 19:56:47 -0500
>Paul DuBois <paul@stripped> wrote:
>> >I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table
>> >"customers" with an auto-incrementing primary key "customer_id".
>>If I insert
>> >a record:
>> >mysql> insert into customers(customer_id) values ("10");
>> >and then ask for the last insert:
>> >mysql> select last_insert_id();
>> >(which I thought was the correct syntax) I get the response "0".
>> You're inserting a specific value into the AUTO_INCREMENT field, which
>> doesn't result in the creation of a new automatic sequence number.
>why don't just use "insert into customers(customer_id) values ("");" ???
Because he apparently wasn't trying to create an automatically generated
sequence number, he was trying insert a specific value and have it be
treated like an automatically generated sequence number.
By the way, it's better to insert NULL in your example than to insert
an empty string; your example relies implicitly on a convert-empty-string-
to-zero operation and on the behavior that inserting zero is currently
that same as inserting NULL.
>Let's call it an accidental feature.
> -- Larry Wall