아래처럼 TB_CODE 와 TB_LIST 테이블이 존재할때
결과값에 CODE_LIS_NM 처럼 ',' 가 붙여진 상태로 나올수 있게 할수 있나요??
TB_CODE
-----------------------
CODE NAME
001 홍길동
002 이순신
003 유관순
004 박찬호
TB_LIST
-----------------------
NO CODE_LIST
1 001,002
2 003
3 003,004
결과값
--------------------------------------
NO CODE_LIST CODE_LIST_NM
1 001,002 홍길동,이순신
2 003 유관순
3 003,004 유관순,박찬호
========================================
select code, name
from (
select '001' CODE, '홍길동' NAME from dual union all
select '002' CODE, '이순신' NAME from dual union all
select '003' CODE, '유관순' NAME from dual union all
select '004' CODE, '박찬호' NAME from dual
) tb_code
select no, code_list
from (
select '1' no, '001,002' code_list from dual union all
select '2' no, '003' code_list from dual union all
select '3' no, '003,004' code_list from dual
) tb_list
부탁드려요~~
|