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 Q: Proper and best way to join 3 tables?

Re: SQL Q: Proper and best way to join 3 tables?

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Tue, 27 Sep 2005 23:11:41 +0200
Message-ID: <89djj11d67j1k8tdan9vfjs3di79d3m8gv@4ax.com>


On Tue, 27 Sep 2005 16:24:54 -0400, Rob Williamson <robw_at_physics.umd.edu> wrote:

>If table A is the parent table and B and C are children with the PK of A
>being a FK in each of B and C.
>
>I have tried:
>select A.pk,B.fk,C.fk
>from A,B,C
>where A.pk = B.fk
>and A.pk = C.fk;
>
>This does not seem to work.
>
>Basically I have an inventory table, a cost table and a comments table.
>
>The part_no key is the pk of Inventory and is also a foreign key in the
>other two tables. I am trying to make a query that returns all the
>Inventory with the Unit_Cost from the Cost table as well as a
>Manufacturer from the Comments table.
>I can do two tables but not 3.
>Help.
>Rob

Please define 'does not seem to work', as that comment must be incorrect looking at the sql.
Please also come up with Oracle version, optimizer being used, and relevant information pertaining to which columns are indexed. Without that information it is impossible to answer your question.

--
Sybrand Bakker, Senior Oracle DBA
Received on Tue Sep 27 2005 - 16:11:41 CDT

Original text of this message

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