Previous Topic: Expansion of Comparison-predicateNext Topic: Expansion of In-predicate


Expansion of Exists-predicate

The exists-predicate tests for the existence of data meeting criteria specified in a subquery.

Syntax

Expansion of exists-predicate

►►─── EXISTS ( subquery ) ────────────────────────────────────────────────────►◄
Parameters
( subquery )

Specifies a subquery that returns a set of zero or more rows. For expanded subquery syntax, see Expansion of Subquery.

Usage

Truth Value of an EXISTS Predicate

The result of an EXISTS predicate is:

Example

With the Unary Operator NOT in a WHERE Parameter

The following SELECT statement identifies employees for whom no expertise information has been stored in the database.

select e1.emp_id
   from employee e1
   where not exists
      (select * from expertise e2
      where e1.emp_id = e2.emp_id);

Note: For more information about search conditions, see Expansion of Search-condition.

More information:

Expansion of Search-condition