3

How to select columns in SQL Server 2008 using WHERE and IN, having 2 columns in the where clause. Here is what I have, however I am getting some error message.

select * from tbl
where (col1, col2) in (VALUES ('x1','y1'),('x2','y2'),....);

Msg 4145, Level 15, State 1, Line 2
An expression of non-boolean type specified in a context where a condition is expected, near ','.

Please advise.

ypercubeᵀᴹ
  • 99,450
  • 13
  • 217
  • 306
Harisudhan
  • 31
  • 1

1 Answers1

1

I would do something along the lines of

select * from tbl where col 1 in (x1,x2) and col 2 in (y1,y2)

Unless you are looking for specific combinations such as xy and y1 together, you didn't specify enough in your question.

Shark50521
  • 11
  • 2