Description
The EXISTS predicate can be used to check for the existence of specific rows. The query_expression returns rows rather than values. The predicate evaluates to true if the number of rows returned by the query_expression is non-zero. The EXISTS predicate can be used inside of a WHERE, HAVING, or JOIN statement.
See also Search Conditions.
Syntax
exists_predicate ::
EXISTS ( query_expression )
Example
SELECT cm_custname FROM custmast WHERE EXISTS (SELECT co_ordrdate FROM custordr WHERE cm_custnumb = custordr.co_custnumb)
In this example, the predicate will evaluate to true if the specified customer has any orders.