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: 3 tables join

Re: 3 tables join

From: Brian Tkatch <N/A>
Date: Fri, 09 Nov 2007 09:15:12 -0500
Message-ID: <2qq8j3tiagpdrfpb60fb256hevepgjd33j@4ax.com>


On Thu, 08 Nov 2007 13:14:05 -0800, DA Morgan <damorgan_at_psoug.org> wrote:

>Brian Tkatch wrote:
>> On Thu, 08 Nov 2007 10:04:07 -0800, DA Morgan <damorgan_at_psoug.org>
>> wrote:
>>
>>> Brian Tkatch wrote:
>>>> On Thu, 08 Nov 2007 07:46:08 -0800, Nick
>>>> <nachiket.shirwalkar_at_gmail.com> wrote:
>>>>
>>>>> I have have 3 tables TableA, TableB and TableC. TableA holds the keys
>>>>> to TableB and TableC. I need a query which will display the details
>>>> >from TableB and TableC depending on the key in TableA.
>>>>> For eg.
>>>>>
>>>>>
>>>>> TableA - columns {id, relatedkey, recordType} ===recordType will hold
>>>>> values like TableB or TableC
>>>>> TableB - columns{id, column1}
>>>>> TableC - columns{id, column1}
>>>>>
>>>>>
>>>>> the query should match the related key to the id of TableA or table B
>>>>> based on recordType and show the column1 value with the TabelA id so
>>>>> output for this should be
>>>>>
>>>>>
>>>>> id recordType column1
>>>>>
>>>>>
>>>>> 1 TableB value of TableB column1
>>>>> 2 TableC value of TableC column1
>>>>>
>>>>>
>>>>> Please help.
>>>>>
>>>>>
>>>>> Cheers
>>>>> Nick
>>>>
>>>> If it is only one value, a subquery can pull the appropriate value. A
>>>> CASE statement based on recordType could specify the two separate
>>>> SELECT sub-queries, and execute the appropriate one.
>>>>
>>>> B.
>>> This is school work cross-posted to multiple usenet groups. Please don't
>>> provide the answer. Thanks.
>>
>> I assumed it wasn't school work, as the schema is rather ill-defined,
>> and seemed not like what a textbook would include.
>>
>> B.
>
>A business app with objects named TableA, TableB, and TableC?
>Columns named ID and column1 ... and ID is a reserved word in Oracle?
>
>Not a chance. This is schoolwork.

No, a COLUMN that is conditionally FOREIGN KEYed to one of two TABLEs based on a second COLUMN.

B. Received on Fri Nov 09 2007 - 08:15:12 CST

Original text of this message

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