Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL query

Re: SQL query

From: Hemant K Chitale <hkchital_at_singnet.com.sg>
Date: Fri, 26 Aug 2005 22:29:52 +0800
Message-Id: <6.2.1.2.0.20050826222927.01fc3550@pop.singnet.com.sg>

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-l
Received on Fri Aug 26 2005 - 09:31:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US