× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2024 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].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.