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

Instruction

The JOIN clause we used is the most common way of joining tables. It's full name is INNER JOIN. In other words JOIN is a synonym for INNER JOIN; they both mean exactly the same thing.

Some people prefer to use INNER JOIN for the sake of clarity, especially in long queries with different kinds of joins used together.

Exercise

Join the author and book tables using an INNER JOIN.

Show the title of each book together with its rating. Consider only those books that were published by authors who are still alive.

Stuck? Here's a hint!

To select the books for authors who are still alive, you have to select the rows from the author table for which the death_year column is NULL.

You can do this with the following IS NULL condition:

WHERE author.death_year IS NULL

Type:

SELECT
  book.title,
  book.rating
FROM book
INNER JOIN author
  ON book.author_id = author.id
WHERE author.death_year IS NULL;