File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Tree structure problem" Watch "Tree structure problem" New topic
Author

Tree structure problem

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tree structure problem
 
Similar Threads
Compile errors not appearing in eclipse
Generics
problem with textfield
Data Structure
Passed the exam