LAST_INSERT_ID()在多用户环境下的工作方式 [英] LAST_INSERT_ID() how it works at multi-users environment

查看:56
本文介绍了LAST_INSERT_ID()在多用户环境下的工作方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先检查该问题:
将自动生成的索引从一个表插入另一个表桌子
我知道此函数"LAST_INSERT_ID()"可以执行所需的
问题是:我在php脚本中使用它,如果某个用户在"table1"中插入了数据,而在他将"id"插入"table2"中之前,另一个用户在"table1"中插入了数据...那么,"id"将使该函数为第一个用户检索其ID或第二个用户最后一个"的ID ??
我希望检索用户自己第一个用户"插入的"id",所以如果没有实现该怎么做呢?

check that question first:
Inserting an automatically generated index from a table into another table
I got that this function "LAST_INSERT_ID()" do the required
the question is: I'm using that in a php script, what if some user inserted data in "table1" and before he insert the "id" into "table2" another user inserted data into "table1"...then which "id" would the function retrieve for the first user, his id or the id of the second user "the last one"??
I wish to retrieve the "id" that the user himself "the first user" inserted, so if it doesn't achieve that how to do it??

推荐答案

LAST_INSERT_ID()为您提供在其上执行连接的最后一个自动生成的ID,它不会返回MySQL服务器全局生成的最后一个插入ID.

LAST_INSERT_ID() gives you the last autogenerated id on the connection you execute it on, it does not return the last insert id globally produced by the MySQL server.

这篇关于LAST_INSERT_ID()在多用户环境下的工作方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆