Monday, November 24, 2014

IN Operator in SQL SERVER

In Operator

By using where condition with assignment we cant give more than one value if we want to give more than one value in where clause we need to use In operator.

Write a query to get the employee details whose eid is 1002 and 1004

select * from employee1 where eid=1002 or eid=1004’normal approach increases the validations if we give more values

Write a query to get the employee details whose eid is 1001,1003 and 1007
select * from employee1 where eid in (1001,1003,1007)

Write a query to get the employee details whose jobtitle is clerk and manager
select * from employee1 where jobtitle in ('clerk','manager')

If you want to use multiple values in where condition for comparisons like <,<=,>,>= we need to use ANY/ALL/SOME Operators


Thanks
Srinivas

No comments: