RIGHT JOIN with NULL Filter
RIGHT JOIN with NULL Filter is a SQL clause in the JOIN Types category. Anti-join pattern using RIGHT JOIN to find rows in the right table with no match in the left. The syntax is SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id WHERE t1.id IS NULL;. It returns unmatched right rows. A typical example: SELECT d.* FROM employees e RIGHT JOIN departments d ON e.dept_id = d.id WHERE e.dept_id IS NULL; -- Departments with NO employees -- Equivalent to: NOT EXISTS (SELECT 1 FROM employees WHERE dept_id = d.id) -- Same result using LEFT JOIN (more common): SELECT d.* FROM departments d LEFT JOIN employees e ON e.dept_id = d.id WHERE e.dept_id IS NULL; A close relative is INNER JOIN, which returns only rows where there is a match in BOTH tables. The most common JOIN type. A close relative is LEFT JOIN, which returns ALL rows from the left table and matching rows from the right. Unmatched right rows show NULL.