salmane
salmane

Reputation: 4847

mySQL return index after insert

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 :)

Upvotes: 1

Views: 3963

Answers (1)

Your Common Sense
Your Common Sense

Reputation: 157918

for the autoincrement index you can use

SELECT LAST_INSERT_ID()

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

Upvotes: 7

Related Questions