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 reviewed
LEFT JOIN
RIGHT JOIN
FULL JOIN
OUTER JOINS
NATURAL JOIN
Aliases for tables

Instruction

Very well done!

You can select some 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.owner_id;

Instead of all columns (selected with the asterisk *) here we select only three columns: name from table person, brand from table car and model from table car.

We first put the name of the table, then a dot (.), and then the name of the column we want to select.

Exercise

Join the student and room tables so that each student is shown together with the room they live in.

Select the name of the student and room number.

Stuck? Here's a hint!

Type:

SELECT
  student.name,
  room.room_number
FROM student
JOIN room
  ON student.room_id = room.id;