Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 20th, 2003, 01:41 PM
nshnXt nshnXt is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Pune
Posts: 9 nshnXt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No left outer join in oracle 8!!!

hi,

let me know if the subject is wrong;

i got the following workaround for outer joins:
R left outer join S on R.B = S.C;
can be rewritten as:
select * from R, S where R.B = S.C(+);

what if i have a double left outer join
say A left outer join B on (..whatever) left outer join C on(..)

thanx in advance
regards

Reply With Quote
  #2  
Old October 20th, 2003, 03:37 PM
Dan Drillich Dan Drillich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 68 Dan Drillich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Let me try to help by quoting from the book "OCA/OCP Introduction to Oracle 9i SQL", pages 256 and 257:
A left outer join is a join between two tables that returns rows based on the matching condition, as well as unmatched rows from the table to the left of the JOIN clause. For example, the following query returns the country name and city name from the COUNTRIES and LOCATIONS tables, as well as the entire country names from the COUNTRIES table.

SELECT c.country_name, l.city
FROM countries c LEFT OUTER JOIN locations l
ON c.country_id = l.country_id

In pre-9i or traditional Oracle left-outer-join syntax, the query is written as follows:

SELECT c.country_name, l.city
FROM countries , locations l
WHERE l.country_id(+) = c.country_id

Hope it helps,
Dan

Reply With Quote
  #3  
Old October 20th, 2003, 08:39 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 6
probably your query would be look like that:
SELECT e.first_name,e.last_name,d.department_id,d.department_name,l.location_id,l.city
FROM employees e, departments d, locations l
WHERE e.department_id = d.department_id(+)
AND d.location_id = l.location_id(+)

An outer join (indicates by (+)) cannot be combined with another condition using the OR or IN logical operators.

If you need full outer join then use the SET operator to combine the result set of each outer join. As follows:

SELECT empno, ename, sal, deptno
FROM emp
WHERE emp.deptno (+)= deptno.deptn
UNION
SELECT empno, ename, sal, deptno
FROM emp
WHERE emp.deptno = dept.deptno(+)

Reply With Quote
  #4  
Old October 20th, 2003, 11:42 PM
nshnXt nshnXt is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Pune
Posts: 9 nshnXt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanx

thanx for the answers.

Reply With Quote
  #5  
Old May 10th, 2005, 04:25 AM
bryantma bryantma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Holland
Posts: 8 bryantma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 28 m 7 sec
Reputation Power: 0
Send a message via MSN to bryantma Send a message via Yahoo to bryantma
Second level outer join in Oracle?

Hi,

I have a similar problem, but taken to the next level. This is my situation.

I have three tables, A, B and C.

I always have a record in A and I always want to have a recordset that returns this record.

Tables B and C may or may not have data.

Thus,

select a.field1, b.field1 from a, b where a.id1 = b.id1(+)

Works fine.

But when I add C, a lack of matching records in B (and C) will result in no rows returned.

Thus,

select a.field1, b.field1, c.field1 from a, b, c where a.id1 = b.id1(+) and b.id2 = c.id2(+)

does not work.

What is the most efficient SQL to return the matching A row and NULL for B and C?

Many thanks,

Martin

Reply With Quote
  #6  
Old May 10th, 2005, 04:41 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,925 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 20 h 9 m 23 sec
Reputation Power: 279
I have three tables:
T1(A,B)
T2(A, B, C) (C is null)
T3(A, C)(empty table).

This query:
Code:
select t1.* from t1, t2, t3 where
t1.a = t2.a(+) and t2.c = t3.a(+)

returns T1's content, I think that your problem lies somewhere else, check you data for spaces or blanks instead of nulls.

Reply With Quote
  #7  
Old May 10th, 2005, 07:43 AM
bryantma bryantma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Holland
Posts: 8 bryantma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 28 m 7 sec
Reputation Power: 0
Send a message via MSN to bryantma Send a message via Yahoo to bryantma
Quote:
Originally Posted by pabloj
I have three tables:
T1(A,B)
T2(A, B, C)(C Null).
T3(A, C)(empty table).

This query:
Code:
select t1.* from t1, t2, t3 where
t1.a = t2.a(+) and t2.c = t3.a(+)

returns T1's content, I think that your problem lies somewhere else, check you data for spaces or blanks instead of nulls.


Sorry, I obviously didn't make it clear. The problem arrises when T2 and T3 are both empty tables.

Thanks again,

Martin

Reply With Quote
  #8  
Old May 10th, 2005, 08:14 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,925 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 20 h 9 m 23 sec
Reputation Power: 279
Ok, I truncated T2 and redid the query, same results (as expected it returns T1's content).

Reply With Quote
  #9  
Old August 10th, 2005, 10:08 AM
sunilkkn sunilkkn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 1 sunilkkn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
Ok, I truncated T2 and redid the query, same results (as expected it returns T1's content).


hi ,

I have one doubt. If I want to check one column in the tabke T2 also then how can I do it ??

For example

I have three tables:
T1(A,B)
T2(A, B, C) (C is null)
T3(A, C)(empty table).

select t1.* from t1, t2, t3 where
t1.a = t2.a(+) and t2.b(+) = 'TEST' and t2.c = t3.a(+)....

is it correct...but it is not working ....

Reply With Quote
  #10  
Old August 11th, 2005, 09:00 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,925 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 20 h 9 m 23 sec
Reputation Power: 279
sql Code:
Original - sql Code
  1. SELECT t1.* FROM t1, t2, t3 WHERE
  2. t1.a = t2.a(+) AND t2.c = t3.a(+) AND t2.b = 'TEST'

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > No left outer join in oracle 8!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT