Use the EXISTS predicate to test for the existence of certain rows. Following is the syntax diagram for the EXISTS predicate:
►►─┬───────┬─ EXISTS ─ (subselect) ───────────────────────────────────────────►◄ └─ NOT ─┘
Description
Indicates to return a "true" result if at least one row exists in the result table that matches the specifications in the subselect.
A keyword. Use NOT to indicate the return of a "true"result only if no rows exist in the result table matching the specifications in the subselect. In the EXISTS predicate, NOT is a CA Datacom/DB extension.
Specify a subselect. The subselect must be enclosed by parentheses. For more information about the subselect see Subselect.
The predicate evaluates to true only if at least one row matches the conditions specified in the subselect.
The predicate evaluates to false if no row matches the conditions specified in the subselect.
Note: The subselect does not return a value. The result of the predicate cannot be unknown.
Example
This EXISTS predicate is true only if at least one row of the result table contains a value greater than $150,000 for the SALARY column. The result is false if no value for SALARY is greater than $150,000.
EXISTS (SELECT *
FROM EMP
WHERE SALARY > 150000)
|
Copyright © 2014 CA.
All rights reserved.
|
|