Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm not able to understand how CONNECT BY is working below:

SELECT employee_id, last_name, manager_id
   FROM employees
   CONNECT BY PRIOR employee_id = manager_id;


EMPLOYEE_ID LAST_NAME MANAGER_ID
----------- ------------------------- ----------
101 Kochhar 100
108 Greenberg 101
109 Faviet 108
110 Chen 108
111 Sciarra 108
112 Urman 108
113 Popp 108
200 Whalen 101

As per my understanding The CONNECT BY clause specifies the relationship between parent rows and child rows of the hierarchy.

CONNECT BY <child_value> = <parent_value>


PRIOR operator to refer to the parent row. Could you please let me know how this is working? how we get this output? Thank you.
Posted
Comments
syed shanu 13-Mar-14 3:39am    
Chk this link
http://docs.oracle.com/cd/B19306_01/server.102/b14200/queries003.htm

http://www.oracle.com/technetwork/issue-archive/2005/05-may/o35asktom-089705.html
Sanjay Chauhan02 13-Mar-14 5:06am    
Nice explanation about CONNECT BY:

http://welcometooracle.wordpress.com/2012/10/18/hierarchical/
http://stackoverflow.com/questions/11132375/connect-by-in-oracle-sql

1 solution

Nice explanation about CONNECT BY:

http://welcometooracle.wordpress.com/2012/10/18/hierarchical/
http://stackoverflow.com/questions/11132375/connect-by-in-oracle-sql
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900