EXISTS Conditional Expression

Description

The EXISTS conditional expression returns TRUE if one or more results of the execution of the subquery specified on the right exist, and returns FALSE if the result of the operation is an empty set.

Syntax

EXISTS expression

Example

--selecting rows using EXISTS and subquery

SELECT 'raise' FROM db_root WHERE EXISTS(

SELECT * FROM condition_tbl WHERE salary < 2500000);

  'raise'

======================

  'raise'

 

--selecting rows using NOT EXISTS and subquery

SELECT 'raise' FROM db_root WHERE NOT EXISTS(

SELECT * FROM condition_tbl WHERE salary < 2500000);

There are no results.