Split string in Oracle with regexp_substr in order

前端 未结 2 1165
梦谈多话
梦谈多话 2021-01-24 03:29

I have a string in Oracle database, my string is: \'bbb;aaa;qqq;ccc\'

I used regexp for split my string:

select distinct trim(regexp_substr(\'bbb;aaa;qqq         


        
2条回答
  •  [愿得一人]
    2021-01-24 04:25

    You don't need a DISTINCT to get your result; besides, to get the result in a given order, all you need is an ORDER BY clause:

    select trim(regexp_substr('bbb;aaa;qqq;ccc','[^;]+', 1,level) ) as q 
    from dual
    connect by regexp_substr('bbb;aaa;qqq;ccc', '[^;]+', 1, level) is not null
    order by level
    

提交回复
热议问题