MySql - set of time stamped data (timestamp,event) calculating events per day
- by Kevin Ohashi
I have a table:
id, datetime, event
i also have table dates:
date (Y-m-d format)
the problem is some days don't have any events, I would like them to show 0 (or null)
SELECT DATE_FORMAT(table.timestamp, '%Y-%m-%d') ydm, count(table.fkUID) FROM `table` where table.fkUID=$var group by ydm;
is there some way to join or use conditional statements to make the result show:
date|count
----------
2010-05-23| 5
2010-05-24| 0 <--- this line just doesn't exist in my query.
2010-05-26| 3