Back to JOINS, UNION, NULL HANDLING

JOINS - FULL, CROSS JOIN

Understand how FULL JOIN and CROSS JOIN work

10 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Primary Key Defined — Defines the column(s) that uniquely identify a row within a table.
  2. Foreign Key Defined — Defines a column linking to another table's primary key to establish a relationship.
  3. Inner Join Review — Combines rows only where a match exists in both tables based on the join condition.
  4. Left Join Review — Includes all rows from the first table, filling NULLs for non-matching rows from the right table.
  5. Full Join Explained — Combines all data from both tables, filling NULLs where no match exists in either direction.
  6. Union Explained — Stacks datasets vertically while performing a deduplication step on overlapping records.
  7. Union All Explained — Stacks datasets vertically without performing the costly duplicate removal step.
  8. Cross Join Explained — Joins every row of the first table with every row of the second table, creating a Cartesian product.
PDF notes

Frequently asked questions

Why is RIGHT JOIN rarely used in practice?

Any RIGHT JOIN can be rewritten as a LEFT JOIN simply by swapping the order of the tables in the FROM clause. LEFT JOIN is the industry standard.

What happens if I use FULL JOIN without an ON clause?

SQL will typically throw an error because FULL JOIN requires a condition to attempt matching rows and determine where NULLs should be placed.

How does UNION deduplicate records?

The database compares every column of the combined rows to identify and discard exact duplicates before returning the final result set.

Can I use CROSS JOIN to simulate an INNER JOIN?

Yes, by using a WHERE clause after the CROSS JOIN to filter the Cartesian product based on the desired join condition.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.