views:

988

answers:

1

I have a dataview where the interresting columns are length, height, color1, and color2 where color1 and color2 can be any of yellow, red, blue, black, white, or green. What is the best way to apply a filter where I get the rows with a certain length and height but with only the colors red, blue, and green?

The filter below feels a bit 'ugly' when the possible colors grow:

"length > 10 AND height > 10 AND (color1 = 'red' OR color1 = 'blue' OR color1 = 'green') AND (color2 = 'red' OR color2 = 'blue' OR color2 = 'green')"

Or is this the only/simplest way?

+1  A: 

Unfortunately, this is the nature of "SQL style" queries :)

The IN clause might make that query simpler:

"length > 10 AND height > 10 AND color1 IN ('red', 'blue', 'green') AND color2 IN ('red', 'blue', 'green')"
Mehrdad Afshari
It seems alot more readable. Thank you.
Lars