Sorry Trevor,

In fact I seem to have confused LEFT OUTER JOIN with EXCEPTION JOIN. I thought they were the same, but EXCEPTION JOIN will not return values for the right sided file. That's why I couldn't understand why you wanted to change the values from NULL to ' '.

Thanks

-----Message d'origine-----
De : midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] De la part de Trevor Perry
Envoyé : vendredi 7 mars 2008 13:36
À : Midrange Systems Technical Discussion
Objet : Re: SQL LEFT OUTER join

David,

There is not a matching record in the right file for every record in the left file. I want all the records in the left file to be in my select, regardless of the right file having a match. So, LEFT OUTER JOIN does that part.

But, the field I am needing from the right file is a character field, and it defaults to NULL when the right record does not exist. The NULL is causing a problem with a tool I am using, so I wanted to have the default for that field be blanks.

Something like this:
Select l.memberid, l.name, r.employername from members as l left outer join employers as r on l.employer = r.employer

Became this:
Select l.memberid, l.name, coalesce(r.employername, ' ') from members as l left outer join employers as r on l.employer = r.employer

Thanks to Michael and Steve for that quick fix.
Trevor



On 3/7/08 5:14 AM, "David FOXWELL" <David.FOXWELL@xxxxxxxxx> wrote:

Hi,

I read the replies to this post and don't quite understand. I am quite
new to SQL.

I don't understand why u r selecting the records on the left but u
need the fields on the right?

Does this mean your instructions are something like :
Select * from leftfile l LEFT OUTER JOIN rightfile r on l.key = r.key -?

Shouldn't they be :
Select l.* from leftfile l LEFT OUTER JOIN rightfile r on l.key = r.key -?


Thanks






-----Message d'origine-----
De : midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx]
De la part de Trevor Perry
Envoyé : jeudi 6 mars 2008 16:59
À : Midrange Systems Technical Discussion Objet : SQL LEFT OUTER join

All,

I am using a LEFT OUTER JOIN to get all records in the ~left~ file ­
regardless of a record existing in the ~right~ file. It works well,
apart from one thing.

The field I need from the ~right~ file is being filled with NULL when
there is no record there. I really would like blanks in that field rather than NULL.

How do I do that?

Thanks in advance,
Trevor
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at http://archive.midrange.com/midrange-l.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.


This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].