title: Getting count of same fileds in Table SQL
body: <p>I have 3 tables </p>
  
  <pre><code>1)question  
  2)options
  3)answers
  </code></pre>
  
  <p>Table 1 contains list of multiple choice questions. Table 2 contains multiple choices for the question. </p>
  
  <p>Consider an example, I have the question "Which game do you like most?"</p>
  
  <p>It is stored in table 1 with id 1. For this question there are 3 choices in table 2; as "cricket", "football", "tennis" with ids 1,2 &amp; 3.</p>
  
  <p>When a user answer this question the question id, and option id are stored to the third table as if he select football, entry in table 3 is question id and option id. </p>
  
  <p>If another user select same option new entry is stored in table 3.</p>
  
  <p>My need is that I want to get the count of each options in table 3.</p>
  
  <p>Consider 10 users select cricket, 15 users select football, no user select tennis, so I need count as 10,15,0 with its corresponding option id</p>
  
  <p>Table name: questions</p>
  
  <pre><code>--------------------------------
  | id |      question            |
  --------------------------------
  |  1 | which game u like most   |
  </code></pre>
  
  <hr>
  
  <p>Table Name: options</p>
  
  <pre><code>------------------------------------------------
  | id |  qid  |         option_name               |
  ------------------------------------------------
  | 1  |   1   |          cricket                   |
  ------------------------------------------------
  | 2  |   1   |          football                  |
  ------------------------------------------------
  | 3  |   1   |          tennis                    |
  ------------------------------------------------
  </code></pre>
  
  <p>Table Name: answers</p>
  
  <pre><code>--------------------------------------------
  | id | qid | optionId                       |
  --------------------------------------------
  | 1  | 1   | 3                              |
  ---------------------------------------------
  | 2  | 1   | 3                               |
  ----------------------------------------------
  | 3  | 1   | 2                               |
  ----------------------------------------------
  </code></pre>
  
  <p>The above table means that, 2 people choose tennis, 1 people choose football and no one choose cricket. So I need result table as </p>
  
  <pre><code>------------------------------------------------------
  | id | question                | option_name | count |
  ------------------------------------------------------
  | 1  | which game u like most  | cricket     |   0   |
  -------------------------------------------------------
  | 2  | which game u like most  | football    |   1   |
  -------------------------------------------------------
  | 3  | which game u like most  | tennis      |   2    |
  -------------------------------------------------------
  </code></pre>
  
  <p>But when I tried, I didnt get the count for cricket, because no one selected cricket.I must get count of cricket as 0. Can any one help me solve the issue?
  My sql code is </p>
  
  <pre><code>SELECT count(an.optionId) count , op.option_name, q.question from
  questions q, options op, answers an where q.id=1
  and  q.id=op.qid
  and op.id=an.optionId
  group by q.question, op.option_name
  </code></pre>