我试着寻找这个问题的解决办法,但还是被卡住了。似乎很简单(也许是我的无知:)
插入后,我已获取“自动递增”主键。我的问题是,我是否可以在不发送第二个查询

SELECT m.timestamp from My_Table m where id = 123; //i.e., 123 is the id of the row that was just created
的情况下检索最后一次插入的时间戳
来回走动似乎很浪费,但真的是这样吗?
我正在使用Spring的JDBCTemplate来查询MySQL数据库。

最佳答案

重要的是得到最后一个插入的id。检查这个
http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
有时候,没有简单的方法。

08-04 16:20