Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How To Do 3-Way Join??
This solution give only the records who exists in all tables (equality for rout_nbr)
It's possible to add rows that exist only in one table by using outer
join like
select r. rout_nbr,r.rout_desc,d.driver_nbr,t.trailer_nbr
from
route r,driver d,trailer t
where r.rout_nbr(+) = d.rout_nbr
and d.rout_nbr(+) = t.rout_nbr
order by r.rout_nbr,d.driver_nbr,t.trailer_nbr;
the (+) sign say "display empty row if not exists but display row from other table"
Hope this help :-)
-- REIP Jean-Claude Enlevez ".remove.this" de l'adresse (anti-spam) jacari.consultant.remove.this_at_skynet.be TurkBear <jvgreco_at_pop.primenet.com> a écrit dans l'article <344fb014.14558473_at_news.primenet.com>...Received on Thu Oct 23 1997 - 00:00:00 CDT
> "Dianne Siebold" <dsiebold_at_wrightstrat.com> wrote:
>
> >I'm using Oracle 7.3.3 and need to join 3 tables and pull data out
of each
> >of them. The DRIVER and TRAILER tables could have multiple
records for one
> >route.
> >
> >ROUT: ROUT_NBR, ROUT_DESC
> >DRIVER: ROUT_NBR, DRIVER_NBR
> >TRAILER: ROUT_NBR, TRAILER_NBR
>
> Try:
> select r. rout_nbr,r.rout_desc,d.driver_nbr,t.trailer_nbr
> from
> route r,driver d,trailer t
> where
> r.rout_nbr = d.rout_nbr and d.rout_nbr = t.rout_nbr
> order by r.rout_nbr,d.driver_nbr,t.trailer_nbr;
>
> John Greco
> Oracle DBA
>