0PricingLogin
SQL Academy · Lesson

IN vs ANY vs ALL

Compare against sets of values.

What Are IN, ANY, and ALL?

When writing SQL queries, you often need to compare a value against a set of values. SQL gives you three powerful operators for this: IN, ANY, and ALL.

All three can work with subqueries that return a list of values. They look similar but behave differently — choosing the right one can make your query much more expressive and efficient.

The IN Operator

The IN operator checks whether a value matches any value in a list or subquery result. It is the simplest of the three.

The example below retrieves employees who work in the Sales, HR, or Engineering departments.

SELECT name, department
FROM employees
WHERE department IN ('Sales', 'HR', 'Engineering');

All lessons in this course

  1. Correlated Subqueries
  2. EXISTS and NOT EXISTS
  3. IN vs ANY vs ALL
  4. EXISTS vs JOIN Performance
← Back to SQL Academy