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 -> Trying to 'join' either of 2 tables to a third

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

From: Calvin Crumrine <Calvin_Crumrine_at_dced.state.ak.us>
Date: Thu, 26 Apr 2001 15:53:19 -0800
Message-ID: <3AE8B4EF.57F5A89A@dced.state.ak.us>

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 Thu Apr 26 2001 - 18:53:19 CDT

Original text of this message

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