pablopicasso
Programmer
I've a table like:
date | data
---------------------------
2002-09-15 | yeahyeahyeah
2002-09-13 | blahblahblah1
2002-09-13 | blahblahblah2
2002-09-14 | tuttuttut
2002-09-11 | doingdoingdoing
I want to get from this table all the entries in the 3 most recent days (this not the last 3 days counting from today, since it may have been several days since the last entry) In the example, the result would look like:
date | data
---------------------------
2002-09-15 | yeahyeahyeah
2002-09-13 | blahblahblah1
2002-09-13 | blahblahblah2
2002-09-14 | tuttuttut
I've tried this example from the manual, but I can't get what I want.
mysql> SELECT something FROM tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 3;
I've also tried to use DISTINCT in conjunction with LIMIT 3, but that only gets one row per day
date | data
---------------------------
2002-09-15 | yeahyeahyeah
2002-09-13 | blahblahblah1
2002-09-13 | blahblahblah2
2002-09-14 | tuttuttut
2002-09-11 | doingdoingdoing
I want to get from this table all the entries in the 3 most recent days (this not the last 3 days counting from today, since it may have been several days since the last entry) In the example, the result would look like:
date | data
---------------------------
2002-09-15 | yeahyeahyeah
2002-09-13 | blahblahblah1
2002-09-13 | blahblahblah2
2002-09-14 | tuttuttut
I've tried this example from the manual, but I can't get what I want.
mysql> SELECT something FROM tbl_name
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 3;
I've also tried to use DISTINCT in conjunction with LIMIT 3, but that only gets one row per day