Jump to content

Tracking Id Numbers


ckrudelux
 Share

Recommended Posts

Need some help with id numbers.Let's say I create a row with some text in it and it gets an id number by auto_increment so I never know what number it gets and I have some options I want to add in an other table. How do I get the id number from the first table so I can add it to my second?

Example:Step 1 :Inserting sometext gets id number 66Step 2 :Inserting option: The text should be red where id is 66
hope you understand what I'm trying to say.
Link to comment
Share on other sites

If two users post at the same time would this effect the id it gets?
It shouldn't. This gets the ID of the row you just inserted... at the time of the actual insertion, not at the time of calling the function. If two users post at the same time, MySQL will first solve the conflict, then give each client instance the ID of their row. Your ID may not be the last one if two users have posted at the same time, but it is sure that it will be the one the current instance posted.
Link to comment
Share on other sites

It shouldn't. This gets the ID of the row you just inserted... at the time of the actual insertion, not at the time of calling the function. If two users post at the same time, MySQL will first solve the conflict, then give each client instance the ID of their row. Your ID may not be the last one if two users have posted at the same time, but it is sure that it will be the one the current instance posted.
Thanks :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...