MYSQL Left Join month count from two tables : <p>I want to add columns that represent month base counts from other table.</p>

<p>I have 2 tables.</p>

<p><b>Leave application</b></p>

<pre><code>leaveid     Userid      
1            3
2            4
3            5
4            1
</code></pre>

<p><b>Leave Dates</b></p>

<pre><code>dateid    leaveid      leavedates 
1            1          2015-10-06
2            1          2015-10-07 
3            2          2015-11-01
4            2          2015-11-02
5            3          2015-01-01
6            4          2015-02-12
</code></pre>

<p>I want to end up with total leave count based on months:</p>

<pre><code>userid    january     fabruary    march   so on...
1           1           3            1
2           2           0            1
2           3           4            1
</code></pre>
