Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
How to query more than one table
Creating JOINs
6. Join tables using JOIN
Referencing columns
Let's practice

Instruction

Take a look at the following example:

SELECT
  *
FROM Person
JOIN Car
  ON Person.Id = Car.OwnerId;

We want to join the tables Person and Car, so we use the JOIN keyword between their names.

T-SQL should also know how to join the tables, so there is another keyword: ON. After this keyword, we set our condition: join only those rows for which the Id in Person is the same as the OwnerId in Car.

Exercise

Use the new construction JOIN ... ON to join rows from the tables Movie and Director in such a way that each movie is shown together with its director.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Movie
JOIN Director
  ON Movie.DirectorId = Director.Id;