bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL EXISTS Keyword

Concept visual

SQL EXISTS Keyword

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

Start at both ends

EXISTS Keyword

Previous

❮ SQL Keywords

Next

Exists

The EXISTS

command tests for the existence of any record in a subquery, and returns true if the subquery returns one or more records. The following SQL lists the suppliers with a product price less than 20:

Example

SELECT SupplierName

FROM Suppliers

WHERE EXISTS (SELECT ProductName FROM

Products WHERE SupplierId = Suppliers.supplierId AND Price < 20);

The following SQL lists the suppliers with a product price equal to 22:

Example

SELECT SupplierName

FROM Suppliers

WHERE EXISTS (SELECT ProductName FROM

Products WHERE SupplierId = Suppliers.supplierId AND Price = 22);

Previous

❮ SQL Keywords

Next

Previous

SQL EXEC Keyword

Next

SQL FOREIGN KEY Keyword