473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

full outer join question

Hi

I have the following 4 tables and I need to do a fully outerjoin on them.

create table A (a number, b number, c char(10), primary key (a,b))
create table B (a number, b number, c char(10), primary key (a,b))
create table C (a number, b number, c char(10), priamry key (a,b))
create table D (a number, b number, c char(10), priamry key (a,b))

In oracle 9i, the following query returns correct results set, if I were to
join just 2 tables - A & B

select A.a, A.b, A.c, B.c
from A full outer join B on
((A.a = B.a) and (A.b = B.b))

How do I extend this query to do a 4-way join ? Do you think the following
query would work or is there a simpler way ?

select A.a, A.b, A.c, B.c, C.c, D.c
from
A full outer join B on
((A.a=B.a)) and (A.b = B.b))
full outer join C on
((A.a = C.a) and (A.B = C.b)) OR ((B.a = C.a) and (B.b = C.b))
full outer join D on
((A.a = D.a) and (A.b = D.b)) OR ((B.a = D.a) and ((B.b =
D.b )) OR ((C.a = D.a) and (C.b = D.b))
;
Jul 19 '05 #1
1 11653
I think it is imposible I sujest longer and not prety way:

(select A.a, A.b, A.c, B.c
from A ,B
where A.a = B.a(+)
union
select A.a, A.b, A.c, B.c
from A ,B
where A.a (+)= B.a )

union

(select A.a, A.b, A.c, C.c
from A ,C
where A.a = C.a(+)
union
select A.a, A.b, A.c, C.c
from A ,B
where A.a (+)= C.a )

and so on :)) I dont't know how else you can outer join 4 tables
without rethinking design


"Dave" <ad***@comcast.net> wrote in message news:<HHz0b.203937$uu5.36905@sccrnsc04>...
Hi

I have the following 4 tables and I need to do a fully outerjoin on them.

create table A (a number, b number, c char(10), primary key (a,b))
create table B (a number, b number, c char(10), primary key (a,b))
create table C (a number, b number, c char(10), priamry key (a,b))
create table D (a number, b number, c char(10), priamry key (a,b))

In oracle 9i, the following query returns correct results set, if I were to
join just 2 tables - A & B

select A.a, A.b, A.c, B.c
from A full outer join B on
((A.a = B.a) and (A.b = B.b))

How do I extend this query to do a 4-way join ? Do you think the following
query would work or is there a simpler way ?

select A.a, A.b, A.c, B.c, C.c, D.c
from
A full outer join B on
((A.a=B.a)) and (A.b = B.b))
full outer join C on
((A.a = C.a) and (A.B = C.b)) OR ((B.a = C.a) and (B.b = C.b))
full outer join D on
((A.a = D.a) and (A.b = D.b)) OR ((B.a = D.a) and ((B.b =
D.b )) OR ((C.a = D.a) and (C.b = D.b))
;

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: reneecccwest | last post by:
SELECT d.code, d.description, v.code AS divCode, v.descripton AS divDescript, b.code AS brhCode, b.description AS brhDescript FROM Department d FULL OUTER JOIN Division v
7
by: alexcn | last post by:
I have the following query: SELECT dbo.tSymExch.exCode, dbo.tSymGrp.sgCode, dbo.tSymMain.smCode FROM dbo.tSymExch FULL OUTER JOIN dbo.tSymGrp ON dbo.tSymExch.exID =...
2
by: Lee | last post by:
I have two identical schema tables (one in a production library and another in a development library) and I need to be able to easily compare the data in them for errors and omissions. With...
2
by: Cory | last post by:
i have two tables, Event1 and Event2. They both have fields called contactID and eventID in them. Some of the contactID's between the tables are equal and some are not. I want to do a full outer...
1
by: Martijn van Oosterhout | last post by:
Today I got the error: ERROR: FULL JOIN is only supported with mergejoinable join conditions Which is really annoying since a full join is exactly what I wanted. I guess the alternative is to...
2
by: Notgiven | last post by:
I have three tables: table1: table2_ID table3_ID complete table3: table3_ID name
1
by: shilpasharma | last post by:
Hi, Can anybody let me know how I can optimise following Query. Select * from reports where ( exists ( SELECT 1 FROM results_required rr, item_claims_trials ict, results res WHERE...
0
by: brunodamato | last post by:
In the example that follows, I am receiving an incorrect result set in the View. I am looking to get the FULL result set from View_LY and Table_TY. Instead, this View is returning the Common (Equi)...
1
by: Dave | last post by:
Hi I have the following 4 tables and I need to do a fully outerjoin on them. create table A (a number, b number, c char(10), primary key (a,b)) create table B (a number, b number, c ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.