This content has been marked as final. Show 3 replies
user9542267 wrote:What happens when you run it?
Is this query possible?
from cars c
where c.car_class_id = 6
and c.car_id in (case when 1=1 then (11,12,13)
else (15,16,17) end)
I would like to filter the list of cars id base on a condition.
BTW, the 1=1 in the case prevents the ELSE condition from ever happening. You probably put it in just for testing but it looks strange in the posting
No, but you can do it this way without case (I used x = 1 because your real condition is obviously not 1 = 1)
select * from cars c where c.car_class_id = 6 and ( (c.x = 1 and c.car_id in (11,12,13)) or (c.x = 2 and c.car_id in (15,16,17)) ) ;
You got it :)