Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. finding full path of subgroup with t-sql?

finding full path of subgroup with t-sql?

Scheduled Pinned Locked Moved Database
databasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maliheSadat
    wrote on last edited by
    #1

    hi I have a table with this records(GroupId,ParentGroupId,GroupName). i want to show a group with its full path, from main parent to it self like this: red cherry: red cherry>>cherry>>fruit i write a Procedure that give me its parents names,but i want to have a prosedure that append the parents name and give me one string i want to do this for all records in that table thanx for u answers

    M 1 Reply Last reply
    0
    • M maliheSadat

      hi I have a table with this records(GroupId,ParentGroupId,GroupName). i want to show a group with its full path, from main parent to it self like this: red cherry: red cherry>>cherry>>fruit i write a Procedure that give me its parents names,but i want to have a prosedure that append the parents name and give me one string i want to do this for all records in that table thanx for u answers

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      What you need is a common table expression[^] which is recursive processing of a table. This may not be correct as your structure seems to be rigid (you know how many level to the top) and therefor you simply do a bunch of inner joins.

      Select *
      From Fruit
      Inner join Category on Category.CategoryID = Fruit.CategoryID
      Inner Join level2.ID = Category.Level2.ID
      ...

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups