473,396 Members | 1,898 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,396 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 11655
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 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.