Beginner

578. SEMI JOIN

Understand the Semi JOIN concept for returning rows that have at least one matching record.

📘 Lesson 578 of 728 ⏱ 13 min 🎯 Advanced

A Semi JOIN returns rows from one table when a matching row exists in another table, without returning columns from the matching table. SQL commonly expresses this using EXISTS.

Sometimes the requirement is only to confirm that a relationship exists, rather than retrieve the related rows.

Find customers who have placed at least one order.

SQL
SELECT
    c.CustomerID,
    c.CustomerName
FROM Customers c
WHERE EXISTS (
    SELECT 1
    FROM Orders o
    WHERE o.CustomerID = c.CustomerID
);

Used in customer filtering, eligibility checks, validation, and existence-based reporting.

  • Semi JOIN returns rows with a match.
  • EXISTS is a common SQL implementation.
  • Related table columns are not required in the final result.
  • EXISTS stops searching once a match is established in many implementations.
  • Useful for existence checks.
What is a Semi JOIN?

A Semi JOIN returns rows from one table when at least one matching row exists in another table.

How is Semi JOIN commonly written in SQL?

It is commonly expressed using the EXISTS predicate.

Have you finished this lesson?

Introduction to SQL – All Lessons