Re: mysql_db_query & INSERT
| From: | tedd | Date: | Tue, 20 Jun 2006 14:08:06 +0000 |
| Subject: | Re: mysql_db_query & INSERT | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238403@lists.php.net to get a copy of this message | ||
At 8:47 AM +0600 6/20/06, Prathaban Mookiah wrote:
>I have run into a tricky situation and need some help to work my way through
>the problem. I use MySQL.
>
>I accept some data from the user and insert them into two tables.
>
>1. I insert part of the data into the first table. I do not specify the
>primary key field. It is auto generated through auto_increment. All the
>other fields can have duplicates.
>2. Then I want to insert the other part of the data along with the primary
>key that was automatically generated during the previous insert operation
>into the second table.
>
>My problem is this: How do I retrieve the auto generated primary key field
>in the first table during the first insert operation. I cannot go back to
>the table and query using the data I inserted since as I mentioned earlier
>there can be duplicates. I simply cannot retreive the maximum value since
>some other user could have inserted something during that time.
>
>Any ideas?
>
>Thanks in advance.
>
>Cheers,
>
>Prathap
Prathap:
I had a similar problem -- I solved it my generating a unique_id field in the record. That way
whenever I wanted to find a specific record, even among duplicates, I could do so.
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com