获取最新时间戳MySQL的记录 [英] get the records for the latest timestamp mysql
本文介绍了获取最新时间戳MySQL的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取最新日期的所有记录.我的数据库中归档的日期称为recordEntryDate,其格式为2010-01-26 13:28:35
how do I get all the records for latest date. The date filed in my db is called recordEntryDate and it is in this form 2010-01-26 13:28:35
Lang:php DB:mysql
Lang: php DB: mysql
推荐答案
您可以执行以下操作:
SELECT *
FROM table1
WHERE DATE(recordEntryDate) = (
SELECT MAX(DATE(recordEntryDate))
FROM table1
)
请注意,此查询将无法利用recordEntryDate
上的索引.如果您有很多行,那么类似的查询对您来说可能会更快:
Note that this query won't be able to take advantage of an index on recordEntryDate
. If you have a lot of rows this similar query might be faster for you:
SELECT *
FROM table1
WHERE recordEntryDate >= (
SELECT DATE(MAX(recordEntryDate))
FROM table1
)
这篇关于获取最新时间戳MySQL的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文