Re: mysql_db_query & INSERT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux