Get to know the data
JOIN revisited
7. JOIN revisited
LEFT JOIN
RIGHT JOIN
FULL JOIN
OUTER JOINS
Aliases for tables

Instruction

Good, let's get started!

Do you still remember how we joined two tables in Part 2 of our SQL course? Let's review the example we gave for people and their cars:

SELECT
  *
FROM Person
JOIN Car
  ON Person.ID = Car.OwnerID;

That's right, we put the keyword JOIN between the names of two tables. Then, after another keyword (ON), we provide the condition we wish to use when joining the two tables.

In this particular example, we joined the rows where the value of the OwnerID column (Car) matches the value of the ID column (Person). In this way, we joined cars with their owners.

Exercise

Try it yourself. Join the Student and Room tables so that each student is shown together with the room they live in. Select all columns.

Stuck? Here's a hint!

Type:

SELECT
  *
FROM Student
JOIN Room
  ON Student.RoomID = Room.ID;