Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Get to know the data
JOIN revisited
8. JOIN columns revised
LEFT JOIN
RIGHT JOIN
FULL JOIN
OUTER JOINS
Aliases for tables

Instruction

Very nice!

You can select specific columns in a JOIN query. Take a look at the example:

SELECT
  Person.Name,
  Car.Brand,
  Car.Model
FROM Person
JOIN Car
  ON Person.ID = Car.OwnerID;

Instead of all columns (*), we opted to select only three columns: Name from Person, Brand from Car, and Model from Car.

We first put the name of the table, then a dot ., and then the name of the column we want to select. This eliminates ambiguity in case the tables share some of the column names.

Exercise

Show each student's name together with the number of the room they live in.

Select the name of the student and room number.

Stuck? Here's a hint!

Type:

SELECT
  Student.Name,
  Room.RoomNumber
FROM Student
JOIN Room
  ON Student.RoomID = Room.ID;