SQL - Conditionally evaluate WHERE clauses
- by Crimius
I need to get a WHERE clause to only evaluate certain statements. something like:
WHERE field_a = field_b AND
(CASE WHEN <PARAM>type</PARAM> = 5
THEN {field_c = 1 OR field_c = 2}
WHEN <PARAM>type</PARAM> = 6
THEN {field_c = 3 OR field_c = 4}
ELSE field_c = <PARAM>type</PARAM>
so that when the Param type = 5, it only checks if field_c = 1 or 2. Any thoughts?