Browse SQL Topics ▼

Anti-JOIN (Finding Missing Records)

📂 Combining Tables (JOINs) 📘 Lesson 45 of 81

Find inactive, orphaned, or unpurchased records using the classic LEFT JOIN ... WHERE right.id IS NULL pattern.

Anti-JOIN (Finding Missing Records) is an essential topic in SQL and relational database engineering.

Overview

Building on foundational principles introduced in left-outer-join, mastering anti-join (finding missing records) provides the core mental model and practical query skills needed for production relational database engineering.

-- Find customers who have NEVER placed an order:
SELECT c.id, c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.order_id IS NULL;

Key Concepts

  • Understand the fundamental syntax, conventions, and mental model.
  • Avoid common beginner traps, data type mismatches, and performance pitfalls.
  • Apply practical idioms directly in production applications.

[!TIP] Master this concept to build a rock-solid foundation. Next, proceed to right-full-joins.

Test your understanding of Anti-JOIN (Finding Missing Records)

Quick interactive practice questions with instant feedback.

Take Quiz →