Monday, 11 February 2013

How to use IN Operator in SQL Server

SQL Server IN Operator
The IN Operator is used in a Where clause of the SQL Statement to retrieve the records that matches to a list of values.
The IN operator allows you to specify list of values in a WHERE clause for Matching Criteria Syntax:
SELECT Column_name(s) FROM Table_name
WHERE Column_name IN (Value1,Value2,...)

Example :

Suppose we have EMP Table as follows :

Criteria :
If we want to select the Employees belongs to the Dept 1 and 2 , use the below query :
Select *from EMP E WHERE E.Dept_Id IN(1,2)

Result :


No comments:

Post a Comment

Hi User, Thank You for Visiting My Blog. Please Post Your Feedback/Comments/Query.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts