I have a difficult situation. I want to write a sql query that includes the case when clause in the where where clause.
Just:
SELECT * FROM <table> WHERE <Column1> in CASE <Column2> WHEN 1 THEN ('OP', 'CL') WHEN 0 THEN ('RE', 'ST') END
Column1 must be "in", not "=". Because there are several values โโfor column 1. This query returns "Invalid syntax near", ".". error.
Can you give me some suggestion? (Sorry for my bad English.)
EDITOR: I think I misunderstood. If column 2 is 1, the condition must match the value "IN (" OP "," CL ")" else Column 1 is 2, the condition must match the value "IN (" RE "," ST ")".
source share