View Full Version : Resolved Help understanding adjacency model

06-29-2011, 06:09 PM
I've been reading this http://sqllessons.com/categories.html and i'm confused on one part. How does the

18 hunting 4
19 companion 4
20 herding 4

become part of the animals?

select root.name as root_name
, down1.name as down1_name
, down2.name as down2_name
, down3.name as down3_name
from categories as root
left outer
join categories as down1
on down1.parentid = root.id
left outer
join categories as down2
on down2.parentid = down1.id
left outer
join categories as down3
on down3.parentid = down2.id
where root.parentid is null
by root_name
, down1_name
, down2_name
, down3_name

06-29-2011, 06:11 PM
Can be ignored, I worked it out as soon as I posted it