Pages

Thursday, August 16, 2012

Multiple conditions in Where In Clause of SQL Server

Parsing two columns in Where IN Clause of SQL Server

I was struck with this kind of scenario when developing the queries for my support team projects.

Need to compare two tables by passing two values in Where IN Clause.

Something like Where (Column1, Column2) IN .....

The query around worked for me is:

Use dbname
Go

Select column1,column2,..column n from TableA
Inner Join
(Select Column1,Column2,..column n from TableB) B
on
TableA.Column1 = B.Column1
and
TableA.Column2= B.Column2

Go

In the above syntax we can have multiple Where IN Clause condition successfully Applied

Hope the above information helps

Thanks