ALL Operator
- The ALL operator in SQL compares a value to all values in another result set or a set of values.
- ALL returns true if all of the subquery meets the condition.
Example:
Consider the Emp table with columns ID, EmpName, and Salary
ID | EmpName | Salary |
---|---|---|
1 | Diya | 15000 |
2 | Preeti | 30000 |
3 | Prabhu | 40000 |
4 | Arya | 20000 |
if we want to list employees whose salary is greater than 15000, 20000 then it is written as:
SELECT *
FROM Emp
where salary > ALL(15000,20000);
Output:
ID | EmpName | Salary |
---|---|---|
2 | Preeti | 30000 |
3 | Prabhu | 40000 |