MYSQL last_insert_id() and concurrency

别来无恙 提交于 2019-12-28 06:55:29

问题


I have a simple MYSQL question. If I make a query that contains LAST_INSERT_ID() right after an INSERT QUERY running on a web page which has many concurrent users accessing other pages that perform INSERT operations would the value of LAST_INSERT_ID() be adulterated/corrupted?


回答1:


No, it will return the insert id from the current connection. As long as your script hasn't made any other inserts, you will get the one you want.

Also be aware that this will only return a generated ID (e.g. an auto-increment). If you are creating your own ID's it won't return this to you.



来源:https://stackoverflow.com/questions/21185666/mysql-last-insert-id-and-concurrency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!