Export (0) Print
Expand All

EXISTS

SQL Server 2000

Specifies a subquery to test for the existence of rows.

Syntax
EXISTS subquery
Arguments
subquery
Is a restricted SELECT statement.
Result Types

bit

Result Values

Returns TRUE if a subquery contains any rows.

Examples

The following example finds, from the Orders table, all the orders with Washington as the Shipping Region for Employees who are listed in the Employees table in the Northwind database.

SELECT * FROM Orders WHERE ShipRegion = 'WA' AND EXISTS (SELECT EmployeeID FROM Employees AS Emp WHERE Emp.EmployeeID = Orders.EmployeeID)

Show:
© 2014 Microsoft