Home > Database > Mysql Tutorial > body text

oracle 一行变多行

WBOY
Release: 2016-06-07 15:19:38
Original
2527 people have browsed it

1、正则表达式 SELECT distinct T.MY_ID, REGEXP_SUBSTR(T.MY_VALUE, '[^,]', 1, LEVEL) --返回第level次匹配的结果 FROM MY_CHANGE T CONNECT BY LEVEL = REGEXP_COUNT(T.MY_VALUE, ',') 1 --循环次数 ORDER BY T.MY_ID; 2、用connct by rownum 和substr se

1、正则表达式

SELECT distinct T.MY_ID, REGEXP_SUBSTR(T.MY_VALUE, '[^,]', 1, LEVEL)  --返回第level次匹配的结果
FROM MY_CHANGE T
CONNECT BY LEVEL ORDER BY T.MY_ID;



2、用connct by rownum 和substr


select my_id, substr(replace(my_value,',',''),tb2.rn,1)sub from
MY_CHANGE ,(select rownum rn from dual connect by rownum where  substr(regexp_replace(my_value,',',''),tb2.rn,1) is not null
ORDER BY MY_ID;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!