MySQL + SQL · Lesson 74
ANY and ALL Operators
ANY and ALL
ANY and ALL compare a value to a set of values from a subquery.
> ANY= greater than at least one.> ALL= greater than every one.
Examples
-- marks greater than ANY class-10 student (i.e. > the minimum)
SELECT name FROM students
WHERE marks > ANY (SELECT marks FROM students WHERE class = '10');
-- marks greater than ALL class-10 students (i.e. > the maximum)
SELECT name FROM students
WHERE marks > ALL (SELECT marks FROM students WHERE class = '10');
Summary
- > ANY = greater than the smallest in the set.
- > ALL = greater than the largest in the set.