EXISTS

Purpose

This tests whether the specified subquery contains result rows.

Syntax

Exists Predicate

Example
CREATE TABLE t (i DECIMAL);
INSERT INTO t VALUES 1,2;

CREATE TABLE t2 (j DECIMAL);
INSERT INTO t2 VALUES 2;

SELECT i FROM t WHERE EXISTS (SELECT * FROM t2);

SELECT i FROM t WHERE EXISTS (SELECT * FROM t2 WHERE t.i=t2.j);