Using the ANY or SOME Keywords
The ANY keyword denotes that the search condition is TRUE
if
the comparison is TRUE
for at least one of the values
that is returned. If the subquery returns no value, the search condition
is FALSE
. The SOME keyword is a synonym for ANY.
The following conditions are
TRUE
when the total
price is greater than the total price of at least one of the items
in order number 1023. The first condition uses the ANY keyword; the
second uses the MIN aggregate function: total_price > ANY (SELECT total_price FROM items WHERE order_num = 1023) total_price > (SELECT MIN(total_price) FROM items WHERE order_num = 1023)
Using the NOT keyword with an ANY subquery tests whether an expression
is not
TRUE
for all elements that the subquery returns.
For example, the following condition is TRUE
when
the expression total_price is not greater than any selected
value. That is, it is TRUE
when total_price is
greater than none of the total prices in order number 1023. NOT total_price > ANY (SELECT total_price FROM items
WHERE order_num = 1023)