tags:

views:

93

answers:

1

I am using multiple IN operators with AND in my sql query where clause as given below...

---
where ID in (1, 3, 234, 2332, 2123, 989) AND tag in ('wow', 'wonderful')

But surprisingly behaviour of result seems to be of OR type rather then AND type. What I mean is it is ignoring AND operator...

Can you please explain me why?

+1  A: 

I couldn't reproduce the result using SQL Server 2008.

SELECT * FROM 
(
  SELECT 0 AS ID, 'wow' as Tag
) X
WHERE ID in (1, 3, 234, 2332, 2123, 989) AND tag in ('wow', 'wonderful')

Result: No records

SELECT * FROM 
(
  SELECT 1 AS ID, 'wow' as Tag
) X
WHERE ID in (1, 3, 234, 2332, 2123, 989) AND tag in ('wow', 'wonderful')

Result:

ID    Tag
1  wow

Check your code again.

Faiz