About Lesson
MySQL ANY and ALL Operators
The ANY and ALL operators in MySQL are used to compare a value to a set of values returned by a subquery. The ANY operator returns TRUE if any of the subquery values meet the condition, while the ALL operator returns TRUE if all subquery values meet the condition.
Example:
SELECT employee_name
FROM employees
WHERE salary > ANY (
SELECT salary
FROM managers
WHERE department_id = 1
);
This query retrieves the names of employees whose salary is greater than any salary of managers in department 1.
The ANY and ALL operators are commonly used in combination with comparison operators and subqueries to perform complex filtering operations.