tags:

views:

67

answers:

3

What is the difference between in and any operators in sql ?

+4  A: 
SQL>
SQL> -- Use the ANY operator in a WHERE clause to compare a value with any of the values in a list.
SQL>

SQL> -- You must place an =, <>, <, >, <=, or >= operator before ANY.

SQL>
SQL> SELECT *
  2  FROM employee
  3  WHERE salary > ANY (2000, 3000, 4000);

For In Operator

SQL> -- Use the IN operator in a WHERE clause to compare a value with any of the values in a list.

but with the In you cannot use =, <>, <, >, <=, or >=

Pranay Rana
What about ALL ? what are all the possible comparison operators i can use ......
Jagan
=, <>, <, >, <=, or >=
Pranay Rana
A: 

With ANY, you need an operator:

WHERE X > ANY (SELECT Y FROM Z)

With IN, you can't. It's always testing for equality.

Thomas Mueller
+1  A: 
Tejas1810