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

Instruction

Cool! One of the last things we would like to show you is a special kind of JOIN: the CROSS JOIN. Here's the general syntax of a CROSS JOIN:

SELECT *
FROM book
CROSS JOIN author

Cross JOIN image

The result of a CROSS JOIN is known as a Cartesian product. In short CROSS JOIN combines all rows from one with all rows from the right table, essentially producing all possible combinations.

Exercise

Your school is holding a contest in which you're tasked with correctly matching the names of authors to the names of the books they wrote from a list of all book-author pairs.

Generate all possible pairs of book titles and author names. Consider only books whose author's name is Ray Henry.

Stuck? Here's a hint!

Type:

SELECT
  title,
  name
FROM author
CROSS JOIN book
WHERE author.name = 'Ray Henry'