Tuesday, 10 September 2013

SQL OR within WHEN (in CASE)

SQL OR within WHEN (in CASE)

Strangely i could not find this on the web, I need an OR within a when
clause in a case statement, something like:
SELECT type,color,brand,CASE type WHEN "foo" OR "BAR" OR "somethingelse"
THEN SELECT ... FROM .... WHERE .... > ....;
I just cant find a way to make it work, i have tried enclosing it in
parenthesys:
SELECT type,color,brand,CASE type WHEN ("foo" OR "BAR" OR "somethingelse")
THEN SELECT ... FROM .... WHERE .... > ....;
Or in square brackets:
SELECT type,color,brand,CASE type WHEN ["foo" OR "BAR" OR "somethingelse"]
THEN SELECT ... FROM .... WHERE .... > ....;
The problem is that i have more groups of options to check, and make a
single WHEN for each of them, will make my query super long. Nothing, any
advice?

No comments:

Post a Comment