WHERE (Transact-SQL)WHERE (Transact-SQL)

S’applique à :Applies to: ouiSQL ServerSQL Server (toutes les versions prises en charge) yesSQL ServerSQL Server (all supported versions) OuiAzure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database OuiAzure SQL Managed InstanceAzure SQL Managed InstanceYesAzure SQL Managed InstanceAzure SQL Managed Instance ouiAzure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics ouiParallel Data WarehouseParallel Data WarehouseyesParallel Data WarehouseParallel Data WarehouseS’applique à :Applies to: ouiSQL ServerSQL Server (toutes les versions prises en charge) yesSQL ServerSQL Server (all supported versions) OuiAzure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database OuiAzure SQL Managed InstanceAzure SQL Managed InstanceYesAzure SQL Managed InstanceAzure SQL Managed Instance ouiAzure Synapse AnalyticsAzure Synapse AnalyticsyesAzure Synapse AnalyticsAzure Synapse Analytics ouiParallel Data WarehouseParallel Data WarehouseyesParallel Data WarehouseParallel Data Warehouse

Spécifie la condition de recherche déterminant les lignes qui seront retournées par la requête.Specifies the search condition for the rows returned by the query.

Icône du lien de rubrique Conventions de la syntaxe Transact-SQLTopic link icon Transact-SQL Syntax Conventions

SyntaxeSyntax

[ WHERE <search_condition> ]  

Notes

Pour afficher la syntaxe Transact-SQL pour SQL Server 2014 et versions antérieures, consultez Versions antérieures de la documentation.To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.

ArgumentsArguments

< search_condition > Définit les conditions que doivent remplir les lignes à retourner.< search_condition > Defines the condition to be met for the rows to be returned. Le nombre de prédicats inclus dans une condition de recherche est illimité.There is no limit to the number of predicates that can be included in a search condition. Pour plus d’informations sur les prédicats et conditions de recherche, consultez Condition de recherche (Transact-SQL).For more information about search conditions and predicates, see Search Condition (Transact-SQL).

ExemplesExamples

Les exemples suivants montrent comment utiliser certaines conditions de recherche usuelles dans la clause WHERE.The following examples show how to use some common search conditions in the WHERE clause.

R.A. Recherche d'une ligne en utilisant une égalité simpleFinding a row by using a simple equality

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE LastName = 'Smith' ;  

B.B. Recherche de lignes qui contiennent une valeur incluse dans une chaîneFinding rows that contain a value as part of a string

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE LastName LIKE ('%Smi%');  

C.C. Recherche de lignes à l'aide d'un opérateur de comparaisonFinding rows by using a comparison operator

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE EmployeeKey  <= 500;  

D.D. Recherche de lignes qui répondent à l'une des trois conditionsFinding rows that meet any of three conditions

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE EmployeeKey = 1 OR EmployeeKey = 8 OR EmployeeKey = 12;  

E.E. Recherche de lignes qui doivent répondre à plusieurs conditionsFinding rows that must meet several conditions

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE EmployeeKey <= 500 AND LastName LIKE '%Smi%' AND FirstName LIKE '%A%';  

F.F. Recherche de lignes qui figurent dans une liste de valeursFinding rows that are in a list of values

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE LastName IN ('Smith', 'Godfrey', 'Johnson');  

G.G. Recherche de lignes dont la valeur est comprise entre deux valeursFinding rows that have a value between two values

-- Uses AdventureWorksDW  
  
SELECT EmployeeKey, LastName  
FROM DimEmployee  
WHERE EmployeeKey Between 100 AND 200;  

Voir aussiSee Also

DELETE (Transact-SQL) DELETE (Transact-SQL)
Prédicats (Transact-SQL) Predicates (Transact-SQL)
Condition de recherche (Transact-SQL) Search Condition (Transact-SQL)
SELECT (Transact-SQL) SELECT (Transact-SQL)
UPDATE (Transact-SQL) UPDATE (Transact-SQL)
MERGE (Transact-SQL)MERGE (Transact-SQL)