Jump to content

Tracking Id Numbers


ckrudelux

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...