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: When would I want to join a table with itself ?

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

From: Nuno Souto <wizofoz2k_at_yahoo.com.au>
Date: 11 Aug 2003 20:13:01 -0700
Message-ID: <73e20c6c.0308111913.246aa2e9@posting.google.com>


"Terry Dykstra" <dontreply_tddykstra_at_forestoil.ca> wrote in message news:<5UOZa.69378$JT2.1606675_at_news2.telusplanet.net>...
> The standard example: employee table that has the employeeid and managerid.
> To get the employees reporting to a manager you need a self join.
>
> > SQL: When would I want to join a table with itself ? Example please ?
> > Thanks for any help!
> >

In general, any query that requires scalar data from more than one row of the table to show up in every single resultset row is a prime candidate for a self-join.
( Or one of the functions that do it for you, like LAG, RANK, etc.)

Cheers
Nuno Souto
wizofoz2k_at_yahoo.com.au Received on Mon Aug 11 2003 - 22:13:01 CDT

Original text of this message

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