Re: Question about joins, left outer and others - Mailing list pgsql-general

From Jeff Ross
Subject Re: Question about joins, left outer and others
Date
Msg-id 4BE47DE4.2050407@wykids.org
Whole thread Raw
In response to Re: Question about joins, left outer and others  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> Jeff Ross <jross@wykids.org> writes:
>> To get the output I want above, I'd think I'd need to do a left outer join
>> like this:
>
>> jross@wykids localhost# select ed_cat_name as "Level", pp_ed_cat_subject as
>> "Subject", pp_ed_cat_institution as "Institution" from
>> education_categories left outer join people_education_categories on
>> (ed_cat_id = pp_ed_cat_id) where pp_ed_cat_pp_id = 1796;
>
> This query is actually equivalent to a plain join.  The reason is that
> no null-extended row can possibly satisfy the WHERE clause, since the
> WHERE is constraining a field from the inner side of the join.  Remember
> WHERE filters the output of the join.
>
> Possibly what you want is
>
>     select ... from
>     education_categories left outer join people_education_categories on
>     (ed_cat_id = pp_ed_cat_id and pp_ed_cat_pp_id = 1796);
>
>             regards, tom lane
>

Thanks, Tom and Andy.  This is exactly what I was missing.

Jeff Ross

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Question about joins, left outer and others
Next
From: hernan gonzalez
Date:
Subject: psql weird behaviour with charset encodings