Re: newid()

From: Date: Fri, 11 Aug 2000 17:43:52 +0000
Subject: Re: newid()
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-1972@lists.php.net to get a copy of this message
SELECT @@IDENTITY executed after the INSERT statement will return the last inserted identity on SQL Server. Steven Campbell Christopher Cheng wrote: > > By the way, I am using MS SQL Server 7.0. Do you know an equilvalent > function in MS SQL Server? > > Thank you very much. > > -----Original Message----- > From: Mike Hanney [mailto:mike@tradebasics.com] > Sent: Friday, August 11, 2000 9:47 AM > To: chengcsw@netvigator.com; php-db@lists.php.net > Subject: Re: [PHP-DB] newid() > > Hi, > > You need to use something like LAST_INSERT_ID(), depending on what database > you're using (presumably MySQL). > > INSERT INTO foo (auto,text) VALUES(NULL,'text') > INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text') > > I think the LAST_INSERT_ID() function will give you the most recent > auto_increment key on a per connection basis not per thread. If anyone > knows for sure please say. > > Mike. > > At 00:18 12/08/00 -0700, Christopher Cheng wrote: > >My intention is to update the product table and the safety certificate > table > >associated with it. As I execute the SQL statement: > >update products values (newid(), .....) > >can I have the primary key generated by the newid() returned to my php > >script? > > > > > >-- > >PHP Database Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > >For additional commands, e-mail: php-db-help@lists.php.net > >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#1972) next »