title: How to show rows with zero counts in mySQL group by query?
body: <p>I tried looking around for similar solutions but it didn't seem to help much in my case. I have a table as such:</p>
  
  <pre><code>locations =&gt; |longname|name|locations|
  
  topics    =&gt; |longname|name|tag|
  </code></pre>
  
  <p>and I am trying to get the count of longnames with a specific <code>atag</code> for a particular location. The query I have so far also tries to force reordering, which is why you see the <code>location IN</code> and <code>FIELD</code>. However, if there aren't any people in a location for a particular tag, it omits it entirely from the response. I'd like it to return 0. How can I do that?</p>
  
  <pre><code>select count(b.longname) as count, a.location 
   from `topics` b, locations a 
    where tag = 'atag' and a.longname = b.longname 
    and location IN ('Japan', 'France', 'Italy') 
    group by location 
    order by FIELD(location, 'Japan', 'France', 'Italy')
  </code></pre>