Abolfazl Ebadi Abolfazl Ebadi - 3 months ago 9
MySQL Question

how to select records which has a column that has a later time?

I want to select records that has a column that has a later time in mysql.

for example i have this table :



Id | Content | Date
1 | lorem | 2015/05/26
2 | lorem | 2015/05/20
3 | lorem | 2015/05/27
4 | lorem | 2015/06/05
5 | lorem | 2015/05/20
6 | lorem | 2015/06/05
7 | lorem | 2015/03/14



I want to select Id 4 and 6 because they are closer to now.

Answer

This I think will get you all the rows that contain the most recent date

SELECT *
FROM `table`
WHERE `Date` = (SELECT MAX(`Date`) FROM `table`);