How to Use ANY Operator
Here are few examples of how we can use the ANY operator.
Sample Data tables used in the examples
Products Table
Orders Table
Example 1
In the below example ANY operator is used to check the Price of Product above 50.
Select * from Products where Price = ANY (Select Price from Products where Price > 50)
Output of the above query
Example 2
In the below example ANY operator is used to check for all Products Sold within the price range of 30 and 50
Select * from Products where Price =ANY (Select Price from Products where Price Between 30 and 50)
Output of the above query:
Example 3
In the below example ANY operator is used to check for Specific Products Ordered based on OrderDetailsID
Select * from Products where ProductID > ANY (Select ProductID from OrderDetails where OrderDetailID = 10 )
Output of the above query
SQL Server ANY Operator
In SQL Server there are many different types of Logical operators like ANY, AND, LIKE, EXISTS, NOT, IN, and BETWEEN. The logical operators are used to perform conditional checks in SQL Queries. These operators are very useful to filter and compare single or multiple data in SQL Queries. In this article let us discuss the ‘ANY’ operator available in SQL Server.