Re: Slightly OT: outer joins

From: merlyn(at)stonehenge(dot)com (Randal L(dot) Schwartz)
To: ffabrizio(at)mmrd(dot)com (Fran Fabrizio)
Subject: Re: Slightly OT: outer joins
Date: 2001-11-21 18:52:52
Message-ID: m11yisufaz.fsf@halfdome.holdit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "Fran" == Fran Fabrizio <ffabrizio(at)mmrd(dot)com> writes:

Fran> So, within those contraints Randal hit it right on the nose. I
Fran> was definitely not catching on enough to see that the 'NATURAL'
Fran> option to the joins is an obvious choice, which was part/all of
Fran> my problem. Thanks Randal and everyone!

[..]

>> test=# select * from people natural left join color natural left join food;

Well, even without the natural part of the join, let's presume
that people.id needed to be matched to color.people_id,
you could say that as:

select id, fname, lname, color, favorite_food from
people
left join color on people.id = color.people_id
left join food on people.id = food.people_id

So the main clue wasn't the NATURAL, it was the LEFT JOIN, to give you
the nulls for the table rows that didn't match.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn(at)stonehenge(dot)com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2001-11-21 19:03:14 Re: [PATCHES] Version checking when loading psql
Previous Message roy cabaniss 2001-11-21 18:47:49 incomplete 7.1.3 update and phpPgAdmin