A Semi Join returns rows from one table when a matching row exists in another table without returning the columns from the matching table. EXISTS is a common SQL pattern for implementing a Semi Join.
Semi-join logic is useful when you only need to know whether a relationship exists and want to avoid duplicate rows caused by one-to-many joins.
Find customers who have placed at least one order without returning order details.
SELECT
c.CustomerID,
c.CustomerName
FROM Customers c
WHERE EXISTS (
SELECT 1
FROM Orders o
WHERE o.CustomerID = c.CustomerID
);
Semi joins are useful for eligibility checks, customer activity analysis, validation, and filtering large datasets.
- Semi Join checks for matching records.
- It returns rows from the first dataset only.
- EXISTS is a common implementation.
- It avoids returning columns from the related table.
- It can prevent unnecessary row multiplication.
What is a Semi Join?
A Semi Join returns rows from one table when at least one matching row exists in another table.
Which SQL feature commonly implements a Semi Join?
EXISTS is a common SQL pattern for implementing Semi Join logic.