Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

EXISTS Predicate


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.


exists_predicate ::

EXISTS ( query_expression )


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.