Curriculum
In this tutorial, you will learn how to use the SQL Server ANY
 operator to compare a value with a single-column set of values returned by a subquery.
ANY
 operatorThe ANY
 operator is a logical operator that compares a scalar value with a single-column set of values returned by a subquery.
The following shows the syntax of the ANY
 operator:
scalar_expression comparison_operator ANY (subquery)
In this syntax:
scalar_expression
 is any valid expression.comparison_operator
 is any comparison operator.subquery
 is aÂ
SELECT statement which returns a result set of a single column with the data is the same as the data type of the scalar expression.Suppose the subquery returns a list of values v1
, v2
, …,  vn
. The ANY
 operator returns TRUE
 if any comparison (scalar_expression
, vi
) returns TRUE
. Otherwise, it returns FALSE
.
Note that the SOME
 operator is equivalent to the ANY
 operator.
ANY
 operator exampleThe following example finds the products that were sold with more than two units in a sales order:
SELECT product_name, list_price FROM production.products WHERE product_id = ANY ( SELECT product_id FROM sales.order_items WHERE quantity >= 2 ) ORDER BY product_name;
In this tutorial, you have learned how to use the SQL Server ANY
 operator to compare a value with a single-column set of values.