Re: Grabbing auto_increment during insert?

From: Date: Mon, 07 Oct 2002 19:49:12 +0000
Subject: Re: Grabbing auto_increment during insert?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119130@lists.php.net to get a copy of this message
If you're using MySQL: mysql_insert_id If you're using MSSQL, you need to execute SELECT @@IDENTITY right after your insertion operation. The result will give you the ID of your last insertion. This won't work well if you're doing a bulk insert, though. On Mon, 2002-10-07 at 15:46, Jason Young wrote: > Apologies for what's probably an extremely newbie question.. > > Is there any way to have a database return its auto_increment field > during insert? I have two different tables, when one inserts, I'd like > to be able to assign the value of the new auto_increment field to > another field in another table. > > I guess I COULD go and make the second table auto_increment along with > it, but that would require a complete rewrite, and I'd like to avoid that... > > Anyone have ideas, suggestions, or preferably.. an answer to my question? :) > > Thanks > -Jason > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#119130) next »