| description | WHERE (Transact-SQL) | |||||
|---|---|---|---|---|---|---|
| title | WHERE (Transact-SQL) | Microsoft Docs | |||||
| ms.custom | ||||||
| ms.date | 08/09/2017 | |||||
| ms.prod | sql | |||||
| ms.prod_service | database-engine, sql-database, synapse-analytics, pdw | |||||
| ms.reviewer | ||||||
| ms.technology | t-sql | |||||
| ms.topic | reference | |||||
| f1_keywords |
|
|||||
| dev_langs |
|
|||||
| helpviewer_keywords |
|
|||||
| ms.assetid | a8430421-7bce-4fab-a2d2-56c00a3c6fa4 | |||||
| author | VanMSFT | |||||
| ms.author | vanto | |||||
| monikerRange | >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current |
[!INCLUDE sql-asdb-asdbmi-asa-pdw]
Specifies the search condition for the rows returned by the query.
Transact-SQL Syntax Conventions
[ WHERE <search_condition> ]
[!INCLUDEsql-server-tsql-previous-offline-documentation]
< search_condition > Defines the condition to be met for the rows to be returned. There is no limit to the number of predicates that can be included in a search condition. For more information about search conditions and predicates, see Search Condition (Transact-SQL).
The following examples show how to use some common search conditions in the WHERE clause.
-- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE LastName = 'Smith' ; -- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE LastName LIKE ('%Smi%'); -- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE EmployeeKey <= 500; -- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE EmployeeKey = 1 OR EmployeeKey = 8 OR EmployeeKey = 12; -- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE EmployeeKey <= 500 AND LastName LIKE '%Smi%' AND FirstName LIKE '%A%'; -- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE LastName IN ('Smith', 'Godfrey', 'Johnson'); -- Uses AdventureWorksDW
SELECT EmployeeKey, LastName
FROM DimEmployee
WHERE EmployeeKey Between 100 AND 200; DELETE (Transact-SQL)
Predicates (Transact-SQL)
Search Condition (Transact-SQL)
SELECT (Transact-SQL)
UPDATE (Transact-SQL)
MERGE (Transact-SQL)