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

Instruction

Excellent! Now, you should be made aware that JOIN is actually just one, of a few joining methods. It's the most common one so it's always applied by default when you write the keyword JOIN in your SQL statement. Technically speaking, though, its full name is INNER JOIN.

The example from the previous exercise can be just as well written in the following way:

SELECT *
FROM person
INNER JOIN car
  ON person.id = car.owner_id;

Exercise

Now, use the full name INNER JOIN to join the room and equipment tables, so that each piece of equipment is shown together with its room and other relevant columns. The result should have the following columns:

  • room_id – ID of the room.
  • room_number.
  • beds.
  • floor.
  • equipment_id – ID of the equipment.
  • name (of the equipment).

Stuck? Here's a hint!

Type:

SELECT
  room.id AS ROOM_ID,
  room_number,
  beds,
  floor,
  equipment.id AS EQUIPMENT_ID,
  name
FROM room
INNER JOIN equipment
  ON equipment.room_id = room.id;