Operator ANY and ALL

The ANY and ALL operators are used in conjunction with the WHERE or HAVING clause. The ANY operator returns TRUE if any of the subqueries meet the conditions. The ALL operator returns TRUE if all subqueries in the query meet the specified condition.

Formula:

SELECT column1
, column2
, column3
FROM Table1
WHERE column1 operator1 ALL
(SELECT column4 FROM Table2 WHERE condition1);

SELECT column1
, column2
, column3
FROM Table1
WHERE column1 operator1 ANY
(SELECT column4 FROM Table2 WHERE condition1);

Important! The operator must be chosen from the standard comparison operators, i.e., =, <>, !=, >, >=, <, <=.

Interesting article? Share further!

Leave A Comment