WebSphere Application Server Network Deployment, Version 6.0.x   Operating Systems: AIX, HP-UX, Linux, Solaris, Windows
             [TIP: Focusing the table of contents and search results]

EXISTS predicate

The exists predicate tests for the presence or absence of a condition specified by a subselect.

Use the syntax:
EXISTS ( subselect )
EXISTS collection-valued-path-expression

The result of EXISTS is true if the subselect returns at least one value or the path expression evaluates to a nonempty collection, otherwise the result is false.

To negate an EXISTS predicate, precede it with the logical operator NOT.

Example: EXISTS predicate

Return departments that have at least one employee earning more than 1000000:
SELECT  OBJECT(d) FROM  DeptBean d 
WHERE EXISTS ( SELECT  1  FROM IN (d.emps) e WHERE  e.salary > 1000000 )
Return departments that have no employees:
SELECT OBJECT(d) FROM DeptBean d 
WHERE NOT EXISTS  ( SELECT 1 FROM IN (d.emps) e)
The above query can also be written as follows:
SELECT OBJECT(d) FROM DeptBean d WHERE NOT EXISTS d.emps



Related concepts
EJB query language
WHERE clause
Related tasks
Using EJB query
Concept topic    

Terms of Use | Feedback

Last updated: Mar 8, 2007 8:14:28 PM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/cque_exists.html

© Copyright IBM Corporation 2002, 2006. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)