by 손님 [2013.07.08 16:14:32]
WITH TBL_A AS ( SELECT 1 AS seq, '11' AS codes FROM dual UNION ALL SELECT 2, '22' FROM dual UNION ALL SELECT 3, '33' FROM dual UNION ALL SELECT 4, '44' FROM dual UNION ALL SELECT 5, '11,33,44' FROM dual UNION ALL SELECT 6, '22,44' FROM dual ), TBL_B AS ( SELECT 11 AS sq, '어쩌구11' AS data1, '저쩌구' AS data2 FROM dual UNION ALL SELECT 22, '어쩌구22', '저쩌구' FROM dual UNION ALL SELECT 33, '어쩌구33', '저쩌구' FROM dual UNION ALL SELECT 44, '어쩌구44', '저쩌구' FROM dual UNION ALL SELECT 55, '어쩌구55', '저쩌구' FROM dual ) select * from ( select regexp_substr ( codes, '[^,]+', 1, lv ) seq , codes from tbl_a a , ( select level lv from dual connect by level <= 10 ) where regexp_count( codes , ',' ) <= lv + 1 and seq = 5 ) a , tbl_b b where a.seq = b.sq