I have a situation here where i need to grab data from past 30 days and get all the dates even if the data is not present in mysql for given dates.
my current query is something like this. lastUpdated is a timestamp column
SELECT Date(a.lastUpdated), count(*)
FROM table1 a
LEFT JOIN table2 b on (a.pgid = b.prod_id)
WHERE Date(lastUpdated) BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()
GROUP BY Date(a.lastUpdated);
This return result like this
Date(a.lastUpdated) count(*)
2016-03-23 1
2016-03-24 14
2016-03-30 65
2016-03-31 1
2016-04-02 1
My question is if its possible to list out all the dates even if the data is not in the mysql. Or any other workaround. I am using PHP 7.0.
I looked around SO but didn't find anything related to my requirements.