| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Jeff Ross <jross(at)wykids(dot)org> |
| Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Question about joins, left outer and others |
| Date: | 2010-05-07 20:41:16 |
| Message-ID: | 248.1273264876@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Jeff Ross <jross(at)wykids(dot)org> writes:
> 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;
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeff Ross | 2010-05-07 20:53:32 | Re: Question about joins, left outer and others |
| Previous Message | Andy Colson | 2010-05-07 20:36:11 | Re: Question about joins, left outer and others |