Subquery comparison operators. ANY (or SOME) returns true if the comparison holds for at least one value in the subquery result. ALL returns true only if the comparison holds for every value. Semantically related to EXISTS and IN but more flexible with comparison operators.
ANY compares a value against any element from a subquery or list (TRUE if any comparison is TRUE); ALL requires all comparisons to be TRUE. Useful for comparative filters against grouped or multi-row subquery results.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✓ Supported | 4.1 | Both ANY and ALL supported since 4.1. SOME is an alias for ANY. Works with =, <>, <, <=, >, >= operators. = ANY(...) is equivalent to IN(...). <> ALL(...) is equivalent to NOT IN(...). If the subquery returns an empty result, ANY returns false and ALL returns true (vacuous truth). NULL in the subquery results causes the same NULL-propagation issues as IN. |
| PostgreSQL | ✓ Supported | 6.0 | Full ANY / ALL / SOME support with all comparison operators. PostgreSQL additionally supports ANY and ALL against arrays (not just subqueries): WHERE val = ANY(ARRAY[1,2,3]) is a common idiom. Array form is often more concise than IN() for literal lists. |
| SQL Server | ✓ Supported | 6.5 | ANY and ALL supported but rarely used in practice. SOME is also accepted as an alias for ANY. SQL Server developers typically use IN / NOT IN / EXISTS patterns instead, which the optimizer handles equivalently. The array form (ANY(ARRAY[...])) is not supported — only the subquery form. |
| Oracle | ✓ Supported | 7 | ANY and ALL supported with all comparison operators. SOME accepted as alias for ANY. Scalar subquery optimization applies. Like SQL Server, Oracle developers typically use IN / EXISTS / aggregate subquery patterns in practice, but ANY / ALL are fully valid. |
| SQLite | ✗ Not Supported | — | ANY and ALL operators are not supported. Use IN, NOT IN, EXISTS, or subqueries with MIN/MAX aggregates as equivalents. |
= ANY(subquery) is exactly equivalent to IN(subquery); <> ALL(subquery) is equivalent to NOT IN(subquery). These relationships are useful for remembering the semantics. The practical mnemonic for choosing between ANY and ALL: ANY behaves like OR (at least one must match); ALL behaves like AND (every one must match). PostgreSQL extends ANY/ALL to work on arrays, which is a common and idiomatic PostgreSQL pattern not found elsewhere. SQLite is the only engine with no support — use MIN/MAX aggregate subqueries as the portable fallback.
Both ANY and ALL supported since 4.1. SOME is an alias for ANY. Works with =, <>, <, <=, >, >= operators. = ANY(...) is equivalent to IN(...). <> ALL(...) is equivalent to NOT IN(...). If the subquery returns an empty result, ANY returns false and ALL returns true (vacuous truth). NULL in the subquery results causes the same NULL-propagation issues as IN.
Full ANY / ALL / SOME support with all comparison operators. PostgreSQL additionally supports ANY and ALL against arrays (not just subqueries): WHERE val = ANY(ARRAY[1,2,3]) is a common idiom. Array form is often more concise than IN() for literal lists.
ANY and ALL supported but rarely used in practice. SOME is also accepted as an alias for ANY. SQL Server developers typically use IN / NOT IN / EXISTS patterns instead, which the optimizer handles equivalently. The array form (ANY(ARRAY[...])) is not supported — only the subquery form.
ANY and ALL supported with all comparison operators. SOME accepted as alias for ANY. Scalar subquery optimization applies. Like SQL Server, Oracle developers typically use IN / EXISTS / aggregate subquery patterns in practice, but ANY / ALL are fully valid.
ANY and ALL operators are not supported. Use IN, NOT IN, EXISTS, or subqueries with MIN/MAX aggregates as equivalents.