oracle中把逗号分割的字符串转换为可放入in的条件语句的字符数列

select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual
connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null

常见的connect by 会在构造序列的时候使用

select rownum from dual connect by rownum<xxx

regexp_substr

function REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)
__srcstr     :需要进行正则处理的字符串
__pattern    :进行匹配的正则表达式
__position   :起始位置,从第几个字符开始正则表达式匹配(默认为1)
__occurrence :标识第几个匹配组,默认为1
__modifier   :模式('i'不区分大小写进行检索;'c'区分大小写进行检索。默认为'c'。)

猜你喜欢

转载自blog.csdn.net/CHS007chs/article/details/84323595
今日推荐