RE: [PHP-DB] Use insert_id in the SQL.
| From: | matt stewart | Date: | Wed, 07 Nov 2001 13:42:52 +0000 |
| Subject: | RE: [PHP-DB] Use insert_id in the SQL. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-14089@lists.php.net to get a copy of this message | ||
only way i can think of is to insert the initial name, then get the "cod",
and use an update command. -
I'd be interested to know if there's a better way!
$sql = "INSERT INTO table (cod, nome, insc) VALUES ('', '$nome',
'')";
$result = mysql_query($sql);
$cod = mysql_insert_id();
$insc=$cod+5000;
$nextsql= "UPDATE table SET insc=$insc WHERE cod=$cod";
-----Original Message-----
From: Bruno Gimenes Pereti [mailto:pereti@ump.edu.br]
Sent: 07 November 2001 13:35
To: PHP-DB
Subject: [PHP-DB] Use insert_id in the SQL.
Hi,
I need to use the inserted key to the same SQL like:
INSERT INTO candidatos (cod, name, insc) VALUES ('', 'BRUNO GIMENES PERETI',
cod+5000);
Who can I do that?
Thank's
Bruno Gimenes Pereti.
--
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
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.291 / Virus Database: 156 - Release Date: 25/10/01
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.291 / Virus Database: 156 - Release Date: 25/10/01