首页 > 代码库 > 循环查询sql带逗号(,)分隔的数据

循环查询sql带逗号(,)分隔的数据

?
1
2
3
4
5
6
select * from sys_role_list where id in
  (select c from
  (with test as (select roleid c from sys_role_info where id=1)
  select substr(t.ca,instr(t.ca, ‘,‘, 1, c.lv) + 1,instr(t.ca, ‘,‘, 1, c.lv + 1) - (instr(t.ca, ‘,‘, 1, c.lv) + 1)) AS c
  from (select ‘,‘ || c || ‘,‘ AS ca,length(c || ‘,‘) - nvl(length(REPLACE(c, ‘,‘)), 0) AS cnt FROM test) t,
    (select LEVEL lv from dual CONNECT BY LEVEL <= 100) c where c.lv <= t.cnt ))