Monday, February 11, 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 :

Thanks,TAMATAM

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog