Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Simple JOINs recap
5. JOINs – recap
Various kinds of JOINs
Filtering with LEFT JOIN and RIGHT JOIN
Summary

Instruction

Alright! The easiest and most basic way to join two tables is to use the JOIN clause. Take a look:

SELECT
  FullName,
  Name
FROM Position
JOIN Employee
ON Position.Id = Employee.PositionId

As you can see, we simply list the name of the first table after the FROM clause as usual. Then, we put the keyword JOIN. And after that we specify the name of the second table.

The ON keyword allows us to specify the condition upon which we should join two tables. In our example, the database joins only those rows from both tables for which the value under the ID column of the table Position is equal to the value under the PositionId column of the Employee table.

Employee Position
FullName PositionId Id Name
Mark Zucchero 1 1 Java Developer
Sara Darling 2 2 Marketing Specialist
Joe Doe 3 3 Java Developer

Exercise

Join the Author table with the Book table.

Select the title of each book and the name of its author.

Stuck? Here's a hint!

Type:

SELECT
  Title,
  Name
FROM Author
JOIN Book
  ON Author.Id = Book.AuthorId