From: Dan Nelson Date: February 2 2003 8:16pm Subject: Re: last_insert_id() returns 0 in windows List-Archive: http://lists.mysql.com/mysql/131474 Message-Id: <20030202201640.GB39529@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In the last episode (Feb 01), Alan said: > Okay, I've seen just about every question on last_insert_id(), except > this one: > > I am running MySQL on Win XP and when I generate a test table (test) > with an AUTO_INCREMENT column (aid) and a second column (a) then use > an insert statement like: INSERT INTO test (a) values (1); then: > SELECT LAST_INSERT_ID(); I get a return value of 0. I considered the > fact that maybe my connection is closing, but when I create the same Are you running these commands from the mysql CLI prompt, or are you using some other tool? If you aren't using the CLI, what does the query "SELECT CONNECTION_ID()" return just before your insert and just after your "SELECT LAST_INSERT_ID()" ? If they are different, your tool is probably opening a new connection for every command you send, and you need to use a different tool :) -- Dan Nelson dnelson@stripped