select *
from departments d
where id in (select regexp_substr(filter,'[^,]+', 1, level) from filters
where filtername='MYFILTE' --use this line if you only want to use one filter, remove if you want to apply all filters
connect by regexp_substr(filter, '[^,]+', 1, level) is not null);
A table like this -
create table filters (filter varchar2(100), filtername varchar2(20));
With data like this-
insert into filters values ('10,20,30','Filter1');
insert into filters values ('40,50,60','Filter2');
Run the query like this (assuming column filter
has values separated by ,
)-
select distinct regexp_substr(filter,'[^,]+', 1, level) from filters
connect by regexp_substr(filter, '[^,]+', 1, level) is not null
order by 1;
Returns this-
REGEXP_SUBSTR(FILTER,'[^,]+',1,LEVEL)
-----------------------------------------
10
20
30
40
50
60
Note- Neither the distinct
nor the order by
matters in your case (i.e. not required in your query, but you can use them anyway).