SQL – ANY
Compare a value against any value returned by a subquery using the ANY operator.
Table of Contents
ANY (also written as SOME) compares a value against each value returned by a subquery and returns TRUE if the comparison is true for at least one of them. WHERE price > ANY (SELECT price FROM courses WHERE category = 'Design') means “return courses priced higher than at least one Design course.”
ANY is less common than IN or EXISTS, but it shines when you need comparison operators (>, <, >=) against a dynamic set of values.
ANY with different operators
= ANY -- equivalent to IN
> ANY -- greater than the minimum
< ANY -- less than the maximum
>= ANY -- at least as large as the minimum
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.
Key Points
- ANY returns TRUE if comparison is true for at least one subquery row
- = ANY is equivalent to IN
-
ANY means “greater than the minimum” value returned
- SOME is a synonym for ANY in standard SQL
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.