Re: Slightly OT: outer joins - Mailing list pgsql-general

From merlyn@stonehenge.com (Randal L. Schwartz)
Subject Re: Slightly OT: outer joins
Date
Msg-id m11yisufaz.fsf@halfdome.holdit.com
Whole thread Raw
In response to Re: Slightly OT: outer joins  (Fran Fabrizio <ffabrizio@mmrd.com>)
List pgsql-general
>>>>> "Fran" == Fran Fabrizio <ffabrizio@mmrd.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@stonehenge.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!

pgsql-general by date:

Previous
From: "Gurunandan R. Bhat"
Date:
Subject: Default conversion of type numeric to text in 7.1.3
Next
From: J Smith
Date:
Subject: Re: PG vs MySQL