Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts

    Help understanding adjacency model

    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?
    Code:
    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
    order 
        by root_name 
         , down1_name 
         , down2_name 
         , down3_name
    Last edited by Nightfire; 06-29-2011 at 06:11 PM. Reason: Worked it out. As soon as I posted it here, I saw how it worked

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Can be ignored, I worked it out as soon as I posted it


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •