title: Get reply numbers in mysql
body: <p>I am working on a product review page where it will display several submitted reviews as well as the number of comments to each of them. </p>
  
  <p>I thought I could use </p>
  
  <pre><code>SELECT title AS review_title,COUNT(id_group) AS Approved_reply_number 
  WHERE approved &lt;&gt; '0' 
  GROUP BY id_group`
  </code></pre>
  
  <p>but read somewhere that it isn't possible to copy the id values into another row on the insert process. So if someone submits a review, the <code>id_group</code> field for the reviews has to be left empty.</p>
  
  <p>Here is the <a href="http://sqlfiddle.com/#!2/5b109/1" rel="nofollow">table example</a>:</p>
  
  <pre><code>CREATE TABLE product_review
      (`ID` int, `title` varchar(21), `id_group` int,`approved` int)
  ;
  
  INSERT INTO product_review
      (`ID`, `title`, `id_group`,`approved`)
  VALUES
      (1, 'AAA', Null,1),
      (2, 'BBB', 1,1),
      (3, 'CCC', Null,1),
      (4, 'DDD', 3,0),
      (5, 'EEE', 1,1),
      (6, 'FFF', Null,1),
      (7, 'GGG', 6,1),
      (8, 'HHH',1,1),
      (9, 'III', 6,1)
  ;
  </code></pre>
  
  <p>Those that are Null in <code>id_group</code> are the submitted reviews. The rest are replies and they contain the id of their corresponding reviews. I was wondering how can I get an output like this:</p>
  
  <pre><code>review_title   approved_reply_number
    AAA             3           
    CCC             0
    FFF             2
  </code></pre>