SQL-Server-In-Operator .

In this session i have discussed the SQL Server In operator .


The SQL Server In operator is used to check the values in given list if value match then it will display . It is alternative of multiple OR operator in select , insert and update or delete .


In syntax

    SELECT column_name from Table_Name
    WHERE Column_name IN( value1 , value2 , value3) 
    


Database Demo

The following data shown by Employee table of abc database .

EmpID EmpName EmpCity EmpEmail
1 Amit Noida amit@gmail.com
2 Amita Noida amita@gmail.com
3 Sandeep Delhi sandeep@gmail.com

In Example .

The below sql code In operator display the Amit and Sandeep from the Employee table .

    SELECT * FROM Employee WHERE EmpName In('Amit','Sandeep')
    

The output is look like below .

EmpID EmpName EmpCity EmpEmail
1 Amit Noida amit@gmail.com
3 Sandeep Delhi sandeep@gmail.com

.


The below sql code In operator display all the name instead the Amita from Employee table .

    SELECT * FROM Employee WHERE EmpName In('Amita')
    

The output is look like below .

EmpID EmpName EmpCity EmpEmail
1 Amit Noida amit@gmail.com
3 Sandeep Delhi sandeep@gmail.com

.

Welcome to AndroidATPoint.

back image                     next image