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

时间:2014-05-01 02:34:49   收藏:0   阅读:670
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 ))

  

循环查询sql带逗号(,)分隔的数据,码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!