note 43529 added to function.mysql-insert-id
| From: | SteveBond at rn2 dot php dot net | Date: | Thu, 24 Jun 2004 15:47:41 +0000 |
| Subject: | note 43529 added to function.mysql-insert-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-71596@lists.php.net to get a copy of this message | ||
If you use this function after doing an INSERT ... SELECT to insert multiple rows at once, you get
the autonumber ID of the *first* row added by the INSERT.
e.g. if there are 4 records in table 'init' that have column 'type' = 2
I want to add these 4 records to table 'game'
Table game has an autonumber column 'game_id' that is currently at 32.
If I do this query:
INSERT INTO game (type, players, rounds)
SELECT type, players, rounds FROM init
WHERE type = 2
Then mysql_insert_id() will return 33, not 36.
----
Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43529
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43529&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43529&report=yes
Search -- http://master.php.net/manage/user-notes.php