Loading

ANY Operator

  • In SQL, the ANY operator compares a value to a set of values. It is typically used in conjunction with a subquery.
  •  The ANY keyword returns true if the subquery values meet the comparison condition.

Syntax:

SELECT column_name
FROM table_name
WHERE column_name operator ANY (subquery);

Let's consider a practical example using a hypothetical table named products:

-- Assuming a products table with columns: product_id, product_name, price
SELECT product_name
FROM products
WHERE price > ANY (SELECT price FROM products WHERE category = 'Electronics');

In this example, the query retrieves the names of products with a price greater than any in the Electronics category.