Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - Database Management and Reference » UltraLite SQL Elements Reference » Expressions in UltraLite » Search conditions in UltraLite

BETWEEN conditions Next Page

EXISTS conditions


Checks whether a subquery produces any rows of query results

Syntax

[ NOT ] EXISTS ( subquery )

Remarks

The EXISTS condition is TRUE if the subquery result contains at least one row, and FALSE if the subquery result does not contain any rows. The EXISTS condition cannot be UNKNOWN.

You can reverse the logic of the EXISTS condition by using the NOT EXISTS form. In this case, the test returns TRUE if the subquery produces no rows, and FALSE otherwise.

Example

List the customers who placed orders after July 13, 2001.

SELECT GivenName, Surname
FROM Customers
WHERE EXISTS (
 SELECT *
 FROM SalesOrders
 WHERE (OrderDate > '2001-07-13') AND
       (Customers.ID = SalesOrders.CustomerID))