title: MySQL Counts per day when count is 0
body: <p>I have a MySQL query:</p>
  
  <pre><code>SELECT COUNT(*) AS total,  DATE_FORMAT(event.serverTime,'%Y-%m-%d') AS sdate
                      FROM event
                      WHERE
                      event.serverTime &gt;= :startDate
                      AND event.serverTime &lt;= :endDate 
                      GROUP BY sdate;
  </code></pre>
  
  <p>Which correctly returns something like:</p>
  
  <pre><code>2011-08-10 =&gt; 5  
  2011-08-15 =&gt; 6
  </code></pre>
  
  <p>However, I would like to also get the dates where there was 0 counts. So assuming startDate is 2011-08-10 and endDate is 2011-08-15, I would see:</p>
  
  <pre><code>2011-08-10 =&gt; 5  
  2011-08-11 =&gt; 0  
  2011-08-12 =&gt; 0  
  2011-08-13 =&gt; 0  
  2011-08-14 =&gt; 0  
  2011-08-15 =&gt; 6
  </code></pre>
  
  <p>I am using PHP so in theory I could do some complex looping and fill up the gaps somehow, but I am wondering if there is a better solution?</p>
  
  <p>Note that if no good MySQL solution exist, I'm also open to good PHP solutions</p>