473,400 Members | 2,163 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,400 software developers and data experts.

FULL OUTER JOIN for oracle8(i)


Dear all,

I need some help. How do I full join two tables (with two columns each)
together using the standard sql way on oracle 8?

David

--
Posted via http://dbforums.com
Jul 19 '05 #1
3 16501
-- Use something like this:

-- First, the table definitions (so you can test this):
create table tab_a (key number primary key, nonkey number);
create table tab_b (key number primary key, nonkey number);

-- Then, populate them:
begin
for i in 1 .. 20 loop
insert into tab_a values (2*i, 2*i);
insert into tab_b values (3*i, 3*i);
end loop;
commit;
end;
/

-- Finally, run the query:
select *
from tab_a, tab_b
where tab_a.key = tab_b.key
union
select a.key, a.nonkey, null, null
from tab_a a
where not exists
(select * from tab_b
where tab_b.key = a.key)
union
select null, null, b.key, b.nonkey
from tab_b b
where not exists
(select * from tab_a
where tab_a.key = b.key);

-- Of course, this can be reduced to something like this:

select *
from tab_a, tab_b
where tab_a.key = tab_b.key (+)
union
select null, null, b.key, b.nonkey
from tab_b b
where not exists
(select * from tab_a
where tab_a.key = b.key);

-- Or this:

select *
from tab_a, tab_b
where tab_a.key (+) = tab_b.key
union
select a.key, a.nonkey, null, null
from tab_a a
where not exists
(select * from tab_b
where tab_b.key = a.key);

-- I posted the *long* version (the first one) since the last two are not
"standard SQL," as you requested in your post.

--
Cheers,
Chris

___________________________________

Chris Leonard, The Database Guy
http://www.databaseguy.com

Brainbench MVP for Oracle Admin
http://www.brainbench.com

MCSE, MCDBA, OCP, CIW
___________________________________

"DMOK" <me*********@dbforums.com> wrote in message
news:30****************@dbforums.com...

Dear all,

I need some help. How do I full join two tables (with two columns each)
together using the standard sql way on oracle 8?

David

--
Posted via http://dbforums.com

Jul 19 '05 #2

How about:

select *
from tab_a
union all
select *
from tab_b;

--
Posted via http://dbforums.com
Jul 19 '05 #3

Thanks to you all!!
:)

David

--
Posted via http://dbforums.com
Jul 19 '05 #4

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

Similar topics

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: 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...
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)...
3
by: DMOK | last post by:
Dear all, I need some help. How do I full join two tables (with two columns each) together using the standard sql way on oracle 8? David -- Posted via http://dbforums.com
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: 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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.