title: MySQL populate empty date values
body: <p>I am running some query's against our incident logging database for our individual customers. What I want to return is all the month names from 2012 and a count of how many open incidents there have been. This works fine for a customer who has been with us for over 12 months but not for a customer who has been with us for a shorter period of time.</p>
  
  <p>The query I have is this:</p>
  
  <pre><code>    SELECT DATE_FORMAT(FROM_UNIXTIME(createdtime/1000), '%Y') as 'Year',
      DATE_FORMAT(FROM_UNIXTIME(createdtime/1000), '%M') as 'Month',
      count(wo.workorderid) as 'Total Logged'
      FROM workorder_threaded wot
      inner join workorder wo
      on wo.workorderid = wot.workorderid
      and wo.siteid = 4806
      and DATE_FORMAT(FROM_UNIXTIME(createdtime/1000), '%Y') &lt;&gt; '2011'
      where wot.workorderid = wot.thd_woid
      GROUP BY DATE_FORMAT(FROM_UNIXTIME(createdtime/1000), '%Y%m')
  </code></pre>
  
  <p>The output I get is this:</p>
  
  <pre><code>    Year    Month       Total Logged
      2012    August      3
      2012    September   356
      2012    October     212
      2012    November    120
  </code></pre>
  
  <p>I need however the following:</p>
  
  <pre><code>    Year      Month       Total Logged
      2012      January     0 
      2012      February    0
      2012      March       0
      2012      April       0
      2012      May         0
      2012      June        0
      2012      July        0 
      2012      August      3
      2012      September   356
      2012      October     212
      2012      November    120
      2012      December    0
  </code></pre>
  
  <p>It doesn't have to be limited by year i.e. the call logging DB has data in this from 2011 so the query can be modified to filter the year range. </p>
  
  <p>I know that this is not populating because the data does not exist and I have seen ways of creating a numbers \ date table and referencing this to populate the date but am struggling to do this. I have also changed around joins and where conditions to no avail.</p>
  
  <p>Thanks in advance.</p>