Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Wie zeige ich Zeilen mit Nullzählungen in mySQL Group by Query?

Vielleicht das? :

SELECT COUNT(t.longname) as cnt, l.location 
FROM locations l 
  LEFT JOIN topics t
    ON  t.longname = l.longname
    AND t.tag = 'atag'      
WHERE l.location IN ('Japan', 'France', 'Italy') 
GROUP BY l.location 
ORDER BY FIELD(l.location, 'Japan', 'France', 'Italy')