
How to query more than one table
Creating JOINs
Referencing columns
Let's practice
12. Put your skills into practice


Nice! Let's put into practice everything we've learnt so far. Are you ready? This example is going to be slightly more complicated, so make sure you remember everything from this part of the course.


Select columns title, production_year from table movie and columns name, birth_year from table director in such a way that a movie is shown together with its director.

Show the column birth_year as born_In. Select only those movies which were filmed when their director was younger than 40 (i.e. the difference between production_year and birth_year must be lower than 40).

Stuck? Here's a hint!


  birth_year AS born_in 
FROM movie 
JOIN director 
  ON director_id = director.id 
WHERE (production_year - birth_year) < 40;