So you would join favoris table and films table and genre table and after that you can just find the user count based on the film genre, below is the query for that
SELECT
gn.ID_genre,
gn.nom,
COUNT(fv.ID_user) AS user_favorite_count
FROM favoris AS fv
INNER JOIN films AS flm ON fv.ID_film = flm.ID_film
INNER JOIN genres AS gn ON gn.ID_genre = flm.ID_genre
GROUP BY gn.ID_genre, gn.nom
ORDER BY COUNT(fv.ID_user) DESC;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…