Re: SQL question

From: DanHW <danhw_at_aol.com>
Date: 9 Jul 1998 22:15:38 GMT
Message-ID: <1998070922153800.SAA07183_at_ladder03.news.aol.com>


>
>Using this SQL example,
>
>table.column (+) = table1.column1
>
>could someone explain the symbol (+)? I've not seen it before and can't
>find a reference to it in the Oracle SQL manual. Any help would be greatly
>appreciated!!
>
>Thanks,
>Dan

The (+) indicates that Oracle is to perform an OUTER JOIN. The way I think of it is that for every row in TABLE1, a dummy record will be made in TABLE such that the join condition is satisfied. All the columns in the 'dummy' record are null.

It sounds a little confusing, but here is a real-world example. I have a table of names, and a table of phone numbers, each with the same person_id. If I want to see the name and the phone, I would normally say

select n.name,p.phone from names n,phones p where n.person_id=p.person_id.

The problem is that I will only get people in the query that have BOTH a phone and a name. If I want to list everybody, and the phone if they have it, I would say

select n.name,p.phone from names n,phones p where n.person_id=p.person_id(+).

By putting the (+) after the phones table's column, a record that has a matching phone will display the matching phone; those that do not have a phone will get a 'dummy' record created, and the phone number will be null. (incidently, if you look at the p.person_id in that dummy row, it is null also).

Hope this clarifies it a little.

Dan Hekimian-Williams Received on Fri Jul 10 1998 - 00:15:38 CEST

Original text of this message