How to query more than one table
3. Multiple tables in the clause FROM
Creating JOINs
Referencing columns
Let's practice

Instruction

We know who directed a specific movie because there is a column named DirectorId in the Movie table. If you take a look at "Midnight in Paris", its DirectorId is 3. So we can now look at the Director table to find that ID 3 is assigned to Woody Allen. And that's how we know he is the director of this movie.

There are quite a few ways of getting information from multiple tables at the same time. We're going to start with the easiest one.

SELECT
  *
FROM Person, Car;

You already know how SELECT * FROM Table works. Now, we just name two tables instead of one, and we separate them with a comma (,). Piece of cake! However, you might find the result slightly surprising. Let's check that out.

Exercise

Get all the data from two tables: Movie and Director.

If there are eight movies and five directors, how many rows will we get in our result? Think about it before you click Run and check code.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Movie, Director;