check that question first:
Inserting an automatically generated index from a table into another table
I got that this function "LAST_INSERT_ID()" do the required
the question is: I'm using that in a php script, what if some user inserted data in "table1" and before he insert the "id" into "table2" another user inserted data into "table1"...then which "id" would the function retrieve for the first user, his id or the id of the second user "the last one"??
I wish to retrieve the "id" that the user himself "the first user" inserted, so if it doesn't achieve that how to do it??
LAST_INSERT_ID() gives you the last autogenerated id on the connection you execute it on, it does not return the last insert id globally produced by the MySQL server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With