티베로(Tibero) 오라클(Oracle)

오라클 트리구조에서 검색

xemaker 2019. 1. 25. 10:47
오라클 트리구조에서 검색을 하려고 했다.

우선 sql은

select level -1 as depth
,code_name
,code_cd
,code_seq
,high_rank
from table
start with high_rank='A'
connect by prior code_cd=high_cd
order siblings by code_seq
;

이런식으로 있을때 그냥 sql 짜듯이 검색조건 where로 넣었다.

결론은 where 로 넣으면 안된다.

from 절 다음에
where code_name like '%경영%'

이렇게 했더니!

뜨억!

결과가 3개 나왔다. 데이터는 1개가 있는데..

아놔..

결론적으로는 저렇게 하면 안되고

from table
start with high_rank='A' and code_name like '%경영%'

이런식으로 where 절이 아닌 start with 에 검색조건을 넣어야 한다.