| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Need to query 4 tables....3 are 'subordinates'...(need outer join?)
This is a database/app design question as best I can figure. I have a
main table called Main which has about 15M rows. It has a two-column
primary key. I want to collect all the information I can find for all
the rows on one-half of that primary key, and then hit the three
'subordinate' tables to get extra information. The pk of table Main
is 2 parts of the 3-part primary keys of each of the remaining 3
tables. I will know the 3rd part of the remaining pk's at runtime (no
worries).
Is there a best approach to gather the information I need? For
instance, I think I finally got my outer join to work for two tables
(the master and one subordinate), and it's already over my head
(shoot, don't even know if it's technically correct, nor how to prove
it sufficiently one way or the other!).
OUTER JOIN W/ ONLY TWO TABLES
FROM t2 LEFT OUTER JOIN t1
ON t1.PK1 = t2.PK1 AND
t1.PK2 = t2.PK2 AND
t2.PK2 = <rt_value>
So, the questions are:
SELECT *
FROM t4, t3, t2
RIGHT OUTER JOIN t1
ON t1.PK1 = t2.PK1 AND t1.PK2 = t2.PK2 AND t2.PK3 = <rt_val>
WHERE t1.PK1 = <rt_val> AND
t3.PK1=t1.PK1 AND t3.PK1=t1.PK2 AND t3.COL=<rt_val> AND
t4.PK1=t1.PK1 AND t4.PK1=t1.PK2 AND t4.COL=<rt_val>
Thanks for any suggestions... Received on Wed Oct 02 2002 - 23:07:30 CDT
![]() |
![]() |