2012년 1월 18일 수요일

Select hierarchical data

with h(id, name, parent, level) as

(

select id, name, parent, 0 as level

from task

where id = 48358

union all

select t.id, t.name, t.parent, t2.level + 1

from task t

inner join h t2 on t.parent = t2.id

)

select * from h;

댓글 없음:

댓글 쓰기