Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

MySQL:SELECT e COUNT na mesma consulta


Algo assim:-
SELECT city.id, city.name, city.slug, COUNT(club.id) AS club_count
FROM city
INNER JOIN club
ON city.id = club.city_id
WHERE club.published = 1
GROUP BY city.id, city.name, city.slug
HAVING club_count > 0