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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Trying to 'join' either of 2 tables to a third

Re: Trying to 'join' either of 2 tables to a third

From: Daniel A. Morgan <dmorgan_at_exesolutions.com>
Date: Thu, 26 Apr 2001 23:05:58 -0700
Message-ID: <3AE90C46.7947676D@exesolutions.com>

Depending on exactly what you are trying to do you could use an "outer join" (the most likely solution) or a "union" or "union all" or some combination of the above. But I definitely think you need to look at how to build an outer join as a first step.

Daniel A. Morgan

Calvin Crumrine wrote:

> Let's see how to explain this. I have customer info in one table & 2
> different types of transaction info in 2 other tables (call it financial
> & informational transactions). All tables carry the customer ID.
>
> I need to retrieve customer & transaction info if customer has either
> specific financial transactions or has specific informational
> transactions. I can do either separately, but can't figure out how to do
> them both. If I join all 3 tables then I get info on customers that have
> both financial & informational transactions.
>
> Select cust_info, financial_info, tran_info
> from cust_table, financial_table, tran_table
> where cust_table.cust_id=financial_table.cust_id
> and cust_table.cust_id=tran_table.tran_id
>
> I've got to put an or in there somewhere, but I'm not sure where. Tried
>
> Select cust_info, financial_info, tran_info
> from cust_table, financial_table, tran_table
> where cust_table.cust_id=financial_table.cust_id
> or cust_table.cust_id=tran_table.tran_id
>
> and haven't gotten results back after 15 minutes. Either SQL*Plus locked
> up or it's joining everything to everything (cust_table only has 5000
> records but financial_table has 1.2 million & tran_table has over
> 150,000).
Received on Fri Apr 27 2001 - 01:05:58 CDT

Original text of this message

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