What do the ANY and ALL operators do in a subquery comparison, and can you give an example?

Last updated 3 July 2026

  • ANY (or SOME) is true if the comparison holds for at least one subquery value: > ANY means above the minimum, and = ANY equals IN.

  • ALL is true only if it holds for every value: > ALL means above the maximum (e.g. salary higher than everyone in dept 10), and <> ALL equals NOT IN.

  • Against an empty set, ALL returns true and ANY returns false.

  • https://dev.mysql.com/doc/en/any-in-some-subqueries.html
  • https://learn.microsoft.com/en-us/sql/t-sql/language-elements/some-any-transact-sql?view=sql-server-ver17
  • https://www.caniusesql.com/f/any-all/
  • https://medium.com/@hemrajsaini1998/mastering-sql-subqueries-in-any-and-all-explained-with-real-examples-28e278b1b014
  • https://dbschema.com/blog/tutorials/sql-any-and-all-operators/
  • https://www.wscubetech.com/resources/sql/any-all
  • https://learn.microsoft.com/en-us/sql/t-sql/language-elements/all-transact-sql?view=sql-server-ver17
  • https://www.sqlservertutorial.net/sql-server-basics/sql-server-all/
All SQL interview questions