MySql - set of time stamped data (timestamp,event) calculating events per day

Posted by Kevin Ohashi on Stack Overflow See other posts from Stack Overflow or by Kevin Ohashi
Published on 2010-05-13T17:42:20Z Indexed on 2010/05/13 17:54 UTC
Read the original article Hit count: 168

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about mysql-query

Related posts about mysql