I wrote the following query :
select film_id, actor_id
from sakila.film_actor
where film_id IN (
select film_id from sakila.film
)
which returns
film_id actor_id
1 1
1 10
1 20
....
2 19
2 85
But I also want to include the name of the film and the name of the actor in this result set.
The film title is in film table and the actor first and last name is the actor table.
Here is how the tables are structured :
Table Columns
actor actor_id, first name, last name
film film_id, title
film_actor actor_id, film_id(foreign keys to film and actor table)
I tried the following query :
select ac.actor_id, ac.first_name, ac.last_name, fm.title from sakila.film_actor as fa inner join sakila.actor ac on fa.actor_id = ac.actor_id inner join sakila.film fm on fa.film_id = fm.film_id;
But this returns list of all films for every actor and I want the other way round. All actors in each film