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'