繁体   English   中英

在单个查询中获取 mysql 中最后插入的时间戳以及主键?

[英]Getting timestamp of last insert in mysql along with primary key in a single query?

我尝试寻找解决此问题的方法,但仍然卡住。 看起来很简单(或者可能是我的无知:)

插入后我已经获取了“自动递增”主键。 我的问题是我可以在不发送第二个查询的情况下检索最后一次插入的时间戳吗

SELECT m.timestamp from My_Table m where id = 123; //i.e., 123 is the id of the row that was just created

go 来回似乎很浪费,但这真的是这样吗?

我正在使用 Spring 的 JDBCTemplate 来查询 MySQL 数据库。

重要的是获取最后插入的 id。 检查此http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html

有时,没有简单的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM