Slide 28
Slide 28 text
階層問い合わせ (with
句による再帰)
WITH r(id, parent_id, category_name)
AS (
select id, parent_id, category_name
from t
where parent_id IS NULL
UNION ALL
select s.id, s.parent_id, s.category_name as parent
from t as s, r
where r.id = s.parent_id
) search depth first BY id set ordcol
SELECT r.parent, r.category_name as name
FROM r
WHERE r.parent_id i not null
ORDER BY ordcol;
UNCOVERTRUTH Tech sake #2
28