0

I'm using the mysql function LAST_INSERT_ID to fetch the data that an user just inputed. For instance, user1 put in "this is user1 input", after using the insert function, I use the LAST_INSERT_ID function to fetch the data just putted in and immediately return it to user 1's browser.

But I'm worried. Suppose millions users insert the data at almost the same time, say user1 input "this is user1 input" and user2 input "this is user 2 input", would the mysql fetch "this is user2 input" to user1?

VolkerK
  • 95,432
  • 20
  • 163
  • 226

1 Answers1

1

There is no such possibility to receive last ID from other user.

It'll get ID from current connection so you don't have to worry about that.

Here's what the manual has to say about LAST_INSERT_ID(), LAST_INSERT_ID(expr):

The ID that was generated is maintained in the server on a per-connection basis. This means that the value returned by the function to a given client is the first AUTO_INCREMENT value generated for most recent statement affecting an AUTO_INCREMENT column by that client.
VolkerK
  • 95,432
  • 20
  • 163
  • 226
Elon Than
  • 9,603
  • 4
  • 27
  • 37