title: Mysql Nested Query with two relational table
body: <pre>
  Table reports :
  id       (int)
  catid    (int)
  pub_date (datetime)
  </pre>
  
  <pre>
  Table categories :
  id           (int)
  parent_id    (int)
  </pre>
  
  <p>I want to get the report results with count(id) 's and group by catid's parent_id.</p>
  
  <p>For example :</p>
  
  <pre>
  <b> Date           Count(parent_id = 1)    Count(parent_id = 2)  Count(parent_id = 3)</b><br> 
  2014-02-24            2                            5                      8 
  <br> 
  </pre>
  
  <p><strong>We should have get the results in only a line per day.</strong></p>
  
  <p>Thanks too much in advance.</p>