[英]get the records for the latest timestamp mysql
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
在我的数据库中提交的日期称为recordEntryDate,它的格式为2010-01-26 13:28:35
Lang: php DB: mysql 郎:php DB:mysql
You could do this: 你可以这样做:
SELECT *
FROM table1
WHERE DATE(recordEntryDate) = (
SELECT MAX(DATE(recordEntryDate))
FROM table1
)
Note that this query won't be able to take advantage of an index on recordEntryDate
. 请注意,此查询将无法利用
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
)
SELECT *
FROM table1
WHERE DATE(recordEntryDate) = (
SELECT MAX((recordEntryDate))
FROM table1
)
Didn't need DATE
there. 那里不需要
DATE
。
Or if you want todays results 或者,如果你想要今天的结果
SELECT *
FROM table
WHERE recordEntryDate > DATE( NOW( ) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.