TITLE 表数据如下图:
ID NAME
1 TEST1,TEST2
2 TEST3,TEST4
3 TEST4,TEST5
4 TEST1,TEST4
5 TEST2,TEST4,TEST5
测试SQL如下:
SELECT ID, REGEXP_SUBSTR(NAME, '[^,]+', 1, LEVEL) NAME
FROM TITLE
CONNECT BY LEVEL <= REGEXP_COUNT(NAME, '[^,]+')
AND ROWID = PRIOR ROWID
AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
ORDER BY NAME;
测试SQL如下:
ID NAME
4 TEST1
1 TEST1
1 TEST2
5 TEST2
2 TEST3
4 TEST4
2 TEST4
5 TEST4
3 TEST4
5 TEST5
3 TEST5
网友评论