Re: newid()
| From: | Mike Hanney | Date: | Fri, 11 Aug 2000 16:47:13 +0000 |
| Subject: | Re: newid() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1968@lists.php.net to get a copy of this message | ||
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