mysql - SQL - Count of each category of film ED CHASE has been in -
this question has answer here:
i'm trying return table category.name , count of number of films ed chase in in category. query should return every category if ed chase hasn't been in film in category.
all have far way select category names. haven't been able tie ed chase in way though.
select category.name film_category inner join category on film_category.category_id = category.category_id, i've tried join these results film_actor, keep getting syntax errors when trying that.
select category.name film_category inner join category on film_category.category_id = category.category_id, inner join film_actor on film_category.film_id = film_actor.film_id
try this:
select c.category_id, c.name, count(a.actor_id) category c left join film_category fc on c.category_id = fc.category_id left join film f on fc.film_id = f.film_id left join film_actor fa on f.film_id = fa.film_id left join actor on fa.actor_id = a.actor_id , a.first_name = 'ed' , a.last_name = 'chase' group c.category_id, c.name the query returns 1 record each category if category has no films associated it. can change , use inner join film_category in case want categories having at least one associated film.

Comments
Post a Comment