Semi-JOINs & EXISTS Pattern: Concept
Module: Joins & Relationships
Semi-join filters left table based on existence of matches in right table. EXISTS returns true if subquery returns any rows. More efficient than JOIN when you only need to check existence.
EXISTS stops at first match (short-circuits). Returns true/false, not actual rows. Semi-join pattern: WHERE EXISTS (subquery). Anti-join: WHERE NOT EXISTS. Often faster than IN or JOIN for existence checks.
EXISTS is essential for filtering based on related data. Understanding when to use EXISTS vs JOIN vs IN is critical for query optimization.
Find customers who have orders (EXISTS). Find products in active categories (EXISTS). Filter users with specific permissions (EXISTS). Semi-joins are efficient for existence checks.