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
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
. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With