Gabor Hojtsy wrote:Read the docs of the function, it is not the same. The function is supposed to return the ID *you have inserted* in this session, while the SELECT return the ID last *inserted by someone*, maybe paralelly to your session.
That is incorrect. Neither of them may be used to obtain the value inserted by some other connection. If they did, they would be useless.
MySQL LAST_INSERT_ID() documentation says: "The last ID that was generated is maintained in the server on a per-connection basis. This means the value the function returns to a given client is the most recent AUTO_INCREMENT value generated by that client. The value cannot be affected by other clients, even if they generate AUTO_INCREMENT values of their own."
Thus it should be the same. Anyway, I am against making this function obsolete.
That is also incorrect. They are not precisely the same.
Jakub Vrana
