언어
union all
땅호720
2024. 7. 8. 13:26
with recursive tree as (
select id,
parent_id,
1 as 'level'
from ecoli_data
where parent_id is null
union
select e1.id,
e1.parent_id,
e2.level + 1
from ecoli_data e1
join tree e2
on e2.id=e1.parent_id -- 크로스 조인
)
select id
from tree
where level=3
order by id
union해줄 때 테이블 구조 일치시키기!