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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL: When would I want to join a table with itself ?

Re: SQL: When would I want to join a table with itself ?

From: Geoff Muldoon <gmuldoon_at_scu.edu.au>
Date: Tue, 12 Aug 2003 08:59:51 +1000
Message-ID: <MPG.19a2caf6b86f700a989685@news.sbt.net.au>


In article <bh8cpo$10r$1_at_slb0.atl.mindspring.net>, newsgroup-responses-1 @waycoolgear.com says...
> SQL: When would I want to join a table with itself ? Example please ?
> Thanks for any help!

The most common one we use is an organisational structure table:

org_unit_id	org_unit_desc	org_unit_parent
1		Head Office		0
2		Branch A		1
3		Sub Branch X		2
4		Branch B		1
5		Agency 543		3
6		Agency 987		4

...etc

Use a self-join to find the "parent" of a unit, or its children.

Geoff M Received on Mon Aug 11 2003 - 17:59:51 CDT

Original text of this message

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