File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Tree structure problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Tree structure problem" Watch "Tree structure problem" New topic

Tree structure problem

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
i have the following table having
--------------- --------------- ----------
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
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Tree structure problem
It's not a secret anymore!