EXISTS Keyword in SQL Server

EXISTS Keyword in SQL Server

The SQL EXISTS condition is used to test for a subquery and is considered to be met, if the subquery returns at least one row. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax


SELECT column_name
FROM table_name
WHERE EXISTS
(SELECT column_name FROM table_name WHERE condition)

Example

SELECT ItemName
FROM Orders
WHERE EXISTS (SELECT PName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price < 100)

 

2020-04-02