Mysql
 sql >> Base de données >  >> RDS >> Mysql

MySQL :SELECT et COUNT dans la même requête

Quelque chose comme ça :-

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