# EXISTS AND NOT EXISTS

The `EXISTS` and `NON EXISTS` command use a subquery to determine whether the subquery returns any rows.

## Syntax

```
SELECT column-list FROM table WHERE
{ EXISTS | NOT EXISTS }
    ( SELECT column FROM table WHERE condition )

```

## Remarks

* If the subquery returns any records, `EXISTS`*subquery* returns `TRUE` and `NOT EXISTS`*subquery* returns `FALSE`.
* If the subquery returns no records, `NOT EXISTS`*subquery* returns `TRUE` and `EXISTS`*subquery* returns `FALSE`.
* SingleStore supports `[NOT] EXISTS` with and without correlated queries.

## Examples

The following query lists the *name* of all the employees in the *employee* table that have a record in the *manager* table.

```sql
SELECT employee.name AS 'Name'
FROM employee
WHERE EXISTS ( SELECT * FROM manager
               WHERE employee.name = manager.name
             );

```

```output

+---------------+
|      Name     |
+---------------+
| Adam Weaver   |
| Leslie Winkle |
| Chris Palms   |
| Joanna Miles  |
+---------------+             

```

The following query lists all the *stock\_symbol* values in the *trade* table which do not match the values in the *stock* field in the *company* table.

```sql
SELECT stock_symbol
FROM trade
WHERE NOT EXISTS ( SELECT * FROM company
                  WHERE symbol = stock_symbol
                ) ;

```

```output

+--------------+
| stock_symbol |
+--------------+
| ZPNM         |
| WQOP         |
+--------------+

```

***

Modified at: June 12, 2026

Source: [/db/v9.1/reference/sql-reference/data-manipulation-language-dml/exists-and-not-exists/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-manipulation-language-dml/exists-and-not-exists/)

(An index of the documentation is available at /llms.txt)
