Home » SQL & PL/SQL » SQL & PL/SQL » Hierargical query (Oracle 9)
Hierargical query [message #388867] Thu, 26 February 2009 07:53 Go to next message
juhani
Messages: 7
Registered: May 2007
Junior Member
Hi,

I need help on this:
I have two tables, Manager and Employee both tables has only column ID.
example:
Manager has values: 10, 11, 12, 13, 14, 15, 16.....300
Employee has values: 100, 101, 102, 103, 104...1000

So, manager can be also employee for other manager and employee can be manager for other employee. (No level- limitation on that stucture). How can I query all in one query, maybe using CONNECT BY PRIOR?

-J

Re: Hierargical query [message #388869 is a reply to message #388867] Thu, 26 February 2009 07:55 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
If both tables have only one column, how are they linked?
These hierarhies are normally done by adding a second column to the table EMP, referring to itself, NOT to manager.
After all, a manager is an EMP as well.

[Updated on: Thu, 26 February 2009 07:56]

Report message to a moderator

Re: Hierargical query [message #388871 is a reply to message #388869] Thu, 26 February 2009 08:04 Go to previous messageGo to next message
juhani
Messages: 7
Registered: May 2007
Junior Member
sorry I forgot this: both tables has only column ID. manager.id=emplyee.id

-
Re: Hierargical query [message #388874 is a reply to message #388871] Thu, 26 February 2009 08:08 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
That doesn't make any sense - how do you tell which employee reports to which manager.

Could you give us a description of these tables.

Better - give us CREATE TABLE scripts, and some INSERT statements so that we can reproduce your data and work out a solution for you.
Previous Topic: Pls help with SQL
Next Topic: make field value as Header but dynamically
Goto Forum:
  


Current Time: Sat Dec 10 16:25:09 CST 2016

Total time taken to generate the page: 0.03892 seconds