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
Referencing columns
11. Filter the joined tables (continued)
Let's practice

Instruction

Excellent! Filtering the results is very important, so let's do another exercise on that. Do you still remember how text values work in T-SQL?

SELECT
  Person.Id,
  Car.Model
FROM Person
JOIN Car
  ON Person.Id = Car.OwnerId
WHERE Car.Brand = N'Fiat';

In the above query, we only select cars branded as N'Fiat'. Piece of cake, right? Let's practice.

Exercise

Select all columns from the tables Movie and Director such that each movie is shown together with its director. Select only those movies that were directed by Steven Spielberg.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Movie
JOIN Director
  ON DirectorId = Director.Id
WHERE Director.Name = N'Steven Spielberg';