Subqueries and Nested SELECTs

A subquery is a query nested inside another query. It's used to perform intermediate calculations or filtering.

SELECT name
FROM employees
WHERE department_id IN (
  SELECT id FROM departments WHERE location = 'New York'
);

This finds employees working in departments based in New York.

← PrevNext →