MySQL ANY, ALL
Last Updated: March 15, 2022
ANY
and ALL
operators can be used to compare operations on a single column value against a range of values.
The operator should have one of the following values (=, <>, !=, >, >=, <, or <=).
WHERE column_name operator ANY (value1, value2, value)
WHERE user_id > ANY (2,3,4,5,6)
ANY Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name operator ANY
(SELECT column_name
FROM table_name
WHERE condition);
Get the names if students whose score is greater than 75
SELECT student_name
FROM students
WHERE student_id = ANY
(SELECT student_id
FROM marks
WHERE score > 75);