SQL query

  • From: Sandeep Dubey <dubey.sandeep@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Fri, 26 Aug 2005 10:23:39 -0400

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
--
//www.freelists.org/webpage/oracle-l

Other related posts: