SELECT
COMPANY_NAME,
COMPANY_ID,
PARENT_ID,
GROUP_ORDER,
COMPANY_DEPT,
USE_YN
FROM
COMPANY
WHERE
COMPANY_ID = #{companyId}
UNION ALL
SELECT
T1.COMPANY_NAME,
T1.COMPANY_ID,
T1.PARENT_ID,
T1.GROUP_ORDER,
T1.COMPANY_DEPT,
T1.USE_YN
FROM
COMPANY T1
INNER JOIN CTE T2 ON T1.PARENT_ID = T2.COMPANY_ID
)
SELECT
COMPANY_NAME,
COMPANY_ID,
PARENT_ID,
GROUP_ORDER,
COMPANY_DEPT,
USE_YN
FROM
CTE
WHERE
1 = 1
COMPANY 계층형 테이블의 하위 그룹 검색
댓글 없음:
댓글 쓰기