반응형
select id,
name,
parent
from (select * from RecursionTest
order by parent, id) products_sorted,
(select @pv :=
'3'
) initialisation
where find_in_set(parent, @pv) > 0
and @pv := concat(@pv,
','
, id)
출처: http://bulkywebdeveloper.tistory.com/109 [건강한 코딩]
with
recursive cte (id, name, parent) as
(
select id,
name,
parent
from recursiontest
where parent = 3
union all
select r.id,
r.name,
r.parent
from recursiontest r
inner join cte
on r.parent = cte.id
)
select * from cte;
출처: http://bulkywebdeveloper.tistory.com/109 [건강한 코딩]
'개발이야기' 카테고리의 다른 글
코드이그나이터CI REST API IP대역대 허용/차단 (0) | 2019.01.22 |
---|---|
node js app.js , express generator, sequelize, pug (0) | 2019.01.09 |
Oracle 12c 인스턴스 클라이언트 설치 시 오류 (0) | 2018.12.10 |
PHP, JS 모바일 체크 (0) | 2018.11.15 |
특정 위치의 문자 변경 (1) | 2018.11.13 |