Mysql中最近更新的行ID [英] Last Updated row ID in Mysql

查看:63
本文介绍了Mysql中最近更新的行ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在处理一个项目.我需要找到最近更新的id.如何在mysql中获取最后更新的行ID?请任何人帮忙吗?

Currently I am working with a project . I required to find last updated id.How can I get last updated row ID in mysql ? Any one help please ?

推荐答案

当生成新的AUTO_INCREMENT值时,您还可以通过使用mysql_query()执行SELECT LAST_INSERT_ID()语句并从语句返回的结果集.

When a new AUTO_INCREMENT value has been generated, you can also obtain it by executing a SELECT LAST_INSERT_ID() statement with mysql_query() and retrieving the value from the result set returned by the statement.

对于LAST_INSERT_ID(),将在每个连接的基础上在服务器中维护最近生成的ID.另一个客户端未更改它.如果用非魔法值(即非NULL且非0的值)更新另一个AUTO_INCREMENT列,则该值甚至不会更改.从多个客户端同时使用LAST_INSERT_ID()AUTO_INCREMENT列是完全有效的.每个客户端将收到该客户端执行的最后一条语句的最后插入的ID.

For LAST_INSERT_ID(), the most recently generated ID is maintained in the server on a per-connection basis. It is not changed by another client. It is not even changed if you update another AUTO_INCREMENT column with a nonmagic value (that is, a value that is not NULL and not 0). Using LAST_INSERT_ID() and AUTO_INCREMENT columns simultaneously from multiple clients is perfectly valid. Each client will receive the last inserted ID for the last statement that client executed.

在此处了解更多信息.

这篇关于Mysql中最近更新的行ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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