Re: Question about joins, left outer and others

From: Andy Colson <andy(at)squeakycode(dot)net>
To: Jeff Ross <jross(at)wykids(dot)org>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question about joins, left outer and others
Date: 2010-05-07 20:36:11
Message-ID: 4BE479BB.5030204@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/7/2010 2:38 PM, Jeff Ross wrote:
> This is going to be simple, I'm sure, but I'm stumped. It's a little
> long but I thought as I wrote it out I'd get the aha! moment and since
> that didn't happen, here goes.
>

snip

> To get the output I want above, I'd think I'd need to do a left outer
> join like this:
>
> jross(at)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;
>
> but that only gives me this:
>
> Level | Subject | Institution
> -----------+--------------------------------+-------------
> Bachelors | Elementary Education/Fine Arts |
> (1 row)
>

Its the "where pp_ed_cat_pp_id = 1796" that is causing it, not the join.

try adding "or pp_ed_cat_pp_id is null"

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-05-07 20:41:16 Re: Question about joins, left outer and others
Previous Message Sorin Schwimmer 2010-05-07 20:02:49 Re: Formatted reports