tags:

views:

41

answers:

1

the way i have it is that I set up an insert command which works well it add the entry to my DB ...since i want to insert other entries in other tables using the unique index that was obtained from the first insertion I do a query obtain the index then reuse it other insert... though this works fine...I am sure there has to be a better way any suggestions? thank you :)

+4  A: 

for the autoincrement index you can use

SELECT LAST_INSERT_ID()

or mysql_insert_id() in PHP if you happen to use this language

Col. Shrapnel
http://www.php.net/manual/en/function.mysql-insert-id.php
Greg K
what if multiple users are doing the same command at the same time....is there any risk that it will take the last Autoincrement from one of them and give it to the other?example... user 1 does the insert user 2 does the insertuser 1 gets the autoincrement valueuser 2 gets the auto increment valueis this scenario possible?
salmane
please read the link above. this function were made by some experienced programmers, who can take care of such things
Col. Shrapnel