|
Conditions are usually made of an attribute, a value and an
operator that forms the condition (eg. Name="John"). But the values themselves
don't have to be constants, they can be the result of another sub-query. We
then talk about nested queries. Using the IN-operator nested queries can be as
deep as necessary.
There are three types of sub-queries that differ in their result:
If only one value or row is returned the normal comparison operators can be used.
If more than one row is returned special operators are used:
IN
examines whether the value exists in the sub-query
<Comparison operator> ALL
the condition must return TRUE for all rows in the sub-query
<Comparison operator> ANY (SOME)
the condition must return TRUE for at least one row in the sub-query
(<Sub-query>) AS <Name>