This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tree structure problem

 
faisal khan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
i have the following table having
EMP BOSS SALARY
--------------- --------------- ----------
Albert NULL 1000
Bert Albert 900
Chuck Albert 900
Donna Chuck 800
Eddie Chuck 700
Fred Chuck 600
Faisal Fred 400

it create a tree structure , and i want to write select statement to get
all employees whose boss is chuck
like donna , eddie, fred and faisal too, bcs fred boss is also Chuck
please help me in solving the problem
Faisal
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal,
You are going to need more than one query. First, you get all the employees whose direct boss is Chuck. Then, you get the employees that have a boss that was returned by your first query. Repeat until your queries don't return any results.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic