title: MYSQL getting poll results table
body: <p>I have 2 tables, one with poll answers and one with votes:</p>
  
  <pre><code>DESC polls;
  
  Field   Type      Null  Key Default Extra
  id      int(11)   NO    PRI NULL    auto_increment
  pollId  int(11)   NO    MUL NULL    
  answer  varchar(150)    YES NULL    
  
  DESC votes;
  Field    Type      Null Key Default Extra
  id       int(11)    NO  PRI NULL    auto_increment
  pollId   int(11)    NO  MUL NULL    
  answerId int(11)    NO  MUL NULL    
  userId   int(11)    NO  MUL NULL    
  </code></pre>
  
  <p>I am trying to get following results with all answers and votes:</p>
  
  <pre><code>pollId answerId numberOfVotes
  1        1          20
  1        2          10
  1        3          0
  </code></pre>
  
  <p>I tried right joins of votes to answers, but it does not work:</p>
  
  <pre><code>SELECT answers.id, COUNT(votes.answerId) FROM answers JOIN votes ON votes.pollId = answers.pollId GROUP BY votes.pollId;
  </code></pre>