如何查找指定列值的最新插入/更新的主键 [英] How to find the primary key of the most recent insert/update of a specified column value

查看:61
本文介绍了如何查找指定列值的最新插入/更新的主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是编程/数据库管理的新手...是否有MySQL函数可查找特定列条目的最新插入/更新的主键?

我有一个使用auto_increment作为主键的数据库,但是一列有多个具有相同值的条目,但是我试图查找此条目的最新插入/更新.

我知道如何编写查询来查找此内容,但我想知道是否有一个函数.

这是我为完成任务而编写的查询,但是如果有执行此操作的功能,请有人让我参与其中吗?

id是主键:
示例-从table1的SELECT ID中,WHERE名称="John Doe" ORDER BY ID DESC LIMIT 1;

Hi,

I''m a novice to programming/database administration...is there a MySQL function to find the primary key of the most recent insert/update of a specific column entry?

I have a data base that''s using auto_increment as the primary key but one column has multiple entries with the same value but I''m trying to find the MOST RECENT INSERT/UPDATE OF THIS ENTRY.

I know how to write the query to find this but I wanted to know if there''s a function.

Here''s the query I''ve written to accomplish the task but if there''s a function that does this would someone please let me in on it?

id is the primary key:
Example - SELECT id from table1 WHERE name = "John Doe" ORDER BY id DESC LIMIT 1;

推荐答案



请阅读以下内容:
http://forums.mysql.com/read.php?20,125996,125998# msg-125998
[
target ="_ blank" title =新窗口"> ^
]


您还可以搜索
mysql中的Scope_Identity或mysql中的MAX.
Hi,

read this:
http://forums.mysql.com/read.php?20,125996,125998#msg-125998
[
target="_blank" title="New Window">^
]


you can also search for
Scope_Identity in mysql or MAX in mysql .


这篇关于如何查找指定列值的最新插入/更新的主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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