Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. What is a semi-join?

SQL · Basics & Joins

What is a semi-join?

Mediumsql-09
semi-joinexistsin

Question

What is a semi-join?

Solution

A semi-join returns rows from the left table when a matching row exists in the right table.

Usually implemented using:

WHERE EXISTS (...)

Example:

SELECT *
FROM customers c
WHERE EXISTS (
    SELECT 1
    FROM orders o
    WHERE o.customer_id = c.id
);

This returns customers who have at least one order.

Unlike an INNER JOIN, a semi-join does not return columns from the right table and does not multiply the left row when multiple matches exist.

EXISTS vs IN:

Both can implement semi-join logic. EXISTS is often convenient for correlated existence checks. IN is simple for comparing against a set of values.

🎯 Put this concept into practice

Solidify this answer with real hands-on interview drills in the browser studio.

Open related drill →
PreviousNext