I am trying to do the following (pseudocode since it doesn't compile):
declare showListedOrSold int = 1 -- get value from config table
select *
from table
where CASE WHEN @showListedOrSold = 0 THEN id IN (1, 2, 5, 6, 10, 11)
WHEN @showListedOrSold = 1 THEN id IN (1, 5, 6, 10, 11)
WHEN @showListedOrSold = 2 THEN id IN (2)
END
Basically depending on value of showListedOrSold
, it should bring back certain id
values.
The statement is not liking the IN clause. What is the correct syntax for this use case?