🔍
👶 Kids📝 Blog About Contact 🚀 Get Started Free

SQL – ALL

Compare a value against every value returned by a subquery using the ALL operator.

ALL is the strict sibling of ANY — it requires the comparison to be true for every value returned by the subquery, not just one. WHERE price > ALL (SELECT price FROM courses WHERE category = 'Design') means “return courses more expensive than every Design course” — i.e., more expensive than even the priciest Design course.

Think of it this way: ANY passes if you beat one opponent, ALL passes only if you beat all opponents.

ALL vs ANY

OperatorPasses when…
> ANYGreater than the MIN of subquery values
> ALLGreater than the MAX of subquery values
< ANYLess than the MAX of subquery values
< ALLLess than the MIN of subquery values

Try It Yourself — Interactive SQL Editor

Edit the query below and click Run Query ▶ to see live results powered by SQLite running directly in your browser.

SQLite – edit & run
Results
← Click Run Query ▶ to see results

Key Points

  • ALL requires the comparison to hold true for every subquery row
  • > ALL is equivalent to being greater than the MAX value
  • If subquery returns no rows, ALL is vacuously TRUE
  • If subquery returns a NULL, ALL comparisons become NULL/Unknown

Pro Tip from CodesCompiler: The best way to learn SQL is to break things intentionally — modify the query above, change the WHERE conditions, try different columns. Every error teaches you something the docs cannot.

In the next lesson, we continue exploring SQL’s powerful feature set to build your database mastery.