skip to Main Content
select * from table where columnType in( case when TRUE then (1,2) end );

This query is giving syntax error Invalid argument types for function 'IFF': (BOOLEAN, ROW(NUMBER(1,0), NUMBER(1,0)), NULL).

It is working fine if I am using a single integer to return in then statement i.e

select * from table where columnType in( case when TRUE then (1) end );

How can I return a list of integers in a case statement?

2

Answers


  1. Check for the "CASE" condition first and then the "IN" condition.

    SELECT * FROM table WHERE 
    <case condition> AND columnType in (1,2) OR
    <case condition> AND columnType in (1)
    
    Login or Signup to reply.
  2. This is an other option to do it using REGEXP:

    select *
    from table 
    where columnType REGEXP ( case when TRUE then '1|2' end );
    

    Demo here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search