Home » SQL & PL/SQL » SQL & PL/SQL » How to select recusrsively in an sql statement
How to select recusrsively in an sql statement [message #23350] Tue, 03 December 2002 22:45 Go to next message
rao
Messages: 25
Registered: July 1999
Junior Member
Hi,
I have a requirement like this.
In an organization, I have a supervisor to whom 10 people are reporting, these 10 are supervisors for another 100 people and it goes like this. a simple hierarchial structure.
In my query if I give the top supervisor, i want all the people under him and sub level till the last level, where no more supervisors

Thanks and Best regards,
Rao
Re: How to select recusrsively in an sql statement [message #23351 is a reply to message #23350] Tue, 03 December 2002 23:02 Go to previous messageGo to next message
Samir
Messages: 32
Registered: April 2002
Member
Go in for a self join type of a structure.

select * from tablea A, tablea B
where A.persontype = "supervisor" and b.persontype = "reports to supervisor"

Maybe if you can give the column names I will be able to help out better
Re: How to select recusrsively in an sql statement [message #23357 is a reply to message #23350] Wed, 04 December 2002 02:29 Go to previous messageGo to next message
Anuka
Messages: 5
Registered: July 2002
Junior Member
Hi,
Please try to use connect by prior clause, i think it will solve ur problem.

Anu
Re: How to select recusrsively in an sql statement [message #23439 is a reply to message #23357] Mon, 09 December 2002 10:54 Go to previous message
Su
Messages: 154
Registered: April 2002
Senior Member
Anu is right. Go for, START WITH and CONNECT BY PRIOR clause in your SELECT statement. It should resolve your problem. Good luck :)
Previous Topic: Year in Roman Numerals
Next Topic: Error Handling in SQL Scripts
Goto Forum:
  


Current Time: Thu May 16 16:47:47 CDT 2024