例:
SELECT `film_id`,COUNT(film_id) AS COUNT FROM films_genres AS FilmsGenre
WHERE genre_id In (4)
GROUP BY film_id,COUNT
HAVING COUNT = 1
返回:
film_id | COUNT
7 1
6 1
但我想要它回归:
film_id
7
6
我如何只返回1个colomn?
最佳答案
要做到这一点,只需移动“COUNT(film_id)”即可.您的HAVING子句将为您完成工作.
原文链接:https://www.f2er.com/mysql/433850.htmlSELECT `film_id` FROM films_genres AS FilmsGenre
WHERE genre_id In (4)
GROUP BY anime_id,film_id
HAVING COUNT(film_id) = 1