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);
像这样的表——
create table filters (filter varchar2(100), filtername varchar2(20));
有了这样的数据——
insert into filters values ('10,20,30','Filter1');
insert into filters values ('40,50,60','Filter2');
像这样运行查询(假设列filter
的值由 分隔,
)-
select distinct regexp_substr(filter,'[^,]+', 1, level) from filters
connect by regexp_substr(filter, '[^,]+', 1, level) is not null
order by 1;
返回这个-
REGEXP_SUBSTR(FILTER,'[^,]+',1,LEVEL)
-----------------------------------------
10
20
30
40
50
60
注意 - 与您的情况distinct
无关order by
(即在您的查询中不需要,但您仍然可以使用它们)。