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

적용 대상: 예SQL Server 예Azure SQL Database 예Azure Synapse Analytics(SQL DW) 예병렬 데이터 웨어하우스 APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure Synapse Analytics (SQL DW) yesParallel Data Warehouse

쿼리가 반환하는 행에 대한 검색 조건을 지정합니다.Specifies the search condition for the rows returned by the query.

항목 링크 아이콘 Transact-SQL 구문 규칙Topic link icon Transact-SQL Syntax Conventions

구문Syntax

[ WHERE <search_condition> ]  

인수Arguments

< search_condition > 행을 반환 하기 위해 충족될 조건을 정의합니다.< 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. 검색 조건 및 조건자에 대한 자세한 내용은 검색 조건(Transact-SQL)을 참조하세요.For more information about search conditions and predicates, see Search Condition (Transact-SQL).

Examples

다음 예에서는 WHERE 절에서 일부 일반 검색 조건을 사용하는 방법을 보여 줍니다.The following examples show how to use some common search conditions in the WHERE clause.

1.A. 간단 비교를 사용하여 행 찾기Finding a row by using a simple equality

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

2.B. 값을 문자열의 일부로 포함하는 행 찾기Finding rows that contain a value as part of a string

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

C.C. 비교 연산자를 사용하여 행 찾기Finding rows by using a comparison operator

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

D.D. 세 가지 조건 중 하나를 충족하는 행 찾기Finding 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. 여러 조건을 모두 충족하는 행 찾기Finding 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. 값 목록에 있는 행 찾기Finding rows that are in a list of values

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

G.G. 두 값 사이의 값을 가진 행 찾기Finding rows that have a value between two values

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

참고 항목See Also

DELETE(Transact-SQL) DELETE (Transact-SQL)
조건자(Transact-SQL) Predicates (Transact-SQL)
검색 조건(Transact-SQL) Search Condition (Transact-SQL)
SELECT(Transact-SQL) SELECT (Transact-SQL)
UPDATE(Transact-SQL) UPDATE (Transact-SQL)
MERGE(Transact-SQL)MERGE (Transact-SQL)