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
2010-09-13 10:06:01
What about ALL ? what are all the possible comparison operators i can use ......
Jagan
2010-09-13 10:18:26
=, <>, <, >, <=, or >=
Pranay Rana
2010-09-13 10:22:19
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
2010-09-13 10:08:27