본문 바로가기

Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Total
Today
Yesterday
관리 메뉴

The Nested Set Model lft rgt 를 이용한 tree단계 뽑기 본문

카테고리 없음

The Nested Set Model lft rgt 를 이용한 tree단계 뽑기

잠이올때마다 2019. 5. 10. 14:19

정말 12시간동안 찾은 끝에 나왔다.

depth 가 계속 이상한식으로 나오는데 하나하나 왜 나오는지 알아 보면서 

root_id가 여러개가 됬을경우 말도 안되게 나오는걸로 확인되었다.

root_id를 기준으로 처리해야 할 것 같다.

나같은경우 project 로 group 1단계

root_id 로 group 2단계

node.subject로 group 3단계

이런식으로 해야 될 것 같은데

일단 어떤형식으로 나오는지 파악.

SELECT  node.*
,(COUNT(parent.subject) - 1) as depth
from (select * from issues where project_id = '22' and root_id ='246') As node,
(select * from issues where project_id = '22' and root_id ='246') As parent
where node.lft between parent.lft and parent.rgt 
group by node.id
order by node.lft;

근데......... 모르겠다.

project 안의 root_id 안의 depth 값을 들고온다라..

 

 

 

Comments