RE: [PHP-DB] newid()
| From: | Christopher Cheng | Date: | Sat, 12 Aug 2000 08:24:56 +0000 |
| Subject: | RE: [PHP-DB] newid() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1969@lists.php.net to get a copy of this message | ||
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