ttttttttttttt ttttttttttttt - 4 months ago 9
SQL Question

Very basic Beginner Join Query for 3 tables

I have 3 tables, 'film', 'actor' and 'cast'. I want to get a list of actors that are in a certain film, but I am brand new to SQL and cannot figure out how to join the tables.

I am comfortable with the SELECT and WHERE, just not the FROM.


  • Film has the following fields:
    id
    ,
    title
    and
    year
    .

  • Actor has the fields
    id
    and
    name
    .

  • Cast has the fields
    filmid
    and
    actorid


Answer

You need to join the tables like this

select a.name
from actor a
join cast c on a.id = c.actorid
join film f on f.id = c.filmid
where f.title = 'your movie title'