Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL query
Read the SQL documentation on the SELECT statement -- the CONNECT BY ... PRIOR clause.
Hemant
At 10:23 PM Friday, Sandeep Dubey wrote:
>Hi,
>
>Can someone help me with the sql query. It is similar to emp_id and
>manager_id.
>
>create table account_test(id number, parent_id number);
>
>insert into account_test values(1,null);
>insert into account_test values(100,1);
>insert into account_test values(101,1);
>insert into account_test values(102,1);
>insert into account_test values(200,100);
>insert into account_test values(201,100);
>insert into account_test values(300,200);
>
>Here id 1 is parent of 100, 101 and 102
>100 is parent of 200 and 201
>300 is child of 200
>
>I need to write a query that id 1 can see all records. 100 can see
>it's and all its child and sub-child i.e. 100, 200, 201 and 300
>200 can get 200 and 300.
>It will be N-tier parent-child.
>
>
>Thanks
>
>Sandeep
>--
>http://www.freelists.org/webpage/oracle-l
Hemant K Chitale
http://web.singnet.com.sg/~hkchital
-- http://www.freelists.org/webpage/oracle-lReceived on Fri Aug 26 2005 - 09:31:59 CDT
![]() |
![]() |