[오라클] start with connect by prior order siblings by


[오라클] start with  connect by prior order siblings by

오라클 쿼리를 짜다보면 계층적으로 정렬해야 될 때가 있다. 예를 들어 메뉴(navigation) 출력. 그럴때 유용하게 사용할 수 있는것이 start with connect by prior order siblings by 이다. order by 로 sort할 경우 모든 데이터를 가지고 정렬을 하지만 order siblings by 각 계층별로 정렬을 한다. 그냥 정렬하면 계층구조가 흐트러지기 때문에 계층구조는 그대로 유지하면서 동일 부모를 가진 자식들끼리의 정렬 기준을 주는 것이다. 예를 들어 아래와 같이 있다고 하면 start with a.parent_id='0' connect by prior a.menu_id=a.parent_id order by siblings by a.sort asc 이러면 부모컬..


원문링크 : [오라클] start with connect by prior order siblings by