bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL Tutorial
SQL•SQL Tutorial

SQL EXISTS Operator

Concept visual

SQL EXISTS Operator

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

The SQL EXISTS Operator

The EXISTS

operator is used in a WHERE clause to check whether a subquery returns any rows.

The EXISTS

operator evaluates to TRUE if the subquery returns at least one row, and FALSE otherwise.

EXISTS Syntax

Select

column_name(s)

From

table_name WHERE EXISTS ( subquery

);

Demo Database

Below is a selection from the "Products" table in the Northwind sample database:

ProductID

ProductName

SupplierID

CategoryID

Unit

Price

Chais

10 boxes x 20 bags 18.00

Chang

Formula

24 - 12 oz bottles

19.00

Aniseed Syrup

Formula

12 - 550 ml bottles

10.00

Chef Anton's Cajun Seasoning

Formula

48 - 6 oz jars

22.00

Chef Anton's Gumbo Mix

36 boxes 21.35 And a selection from the "Suppliers" table:

SupplierID

SupplierName

ContactName

Address

City

PostalCode

Previous

SQL HAVING Clause

Next

SQL ANY Operator