Re: Repost: Syntax - or unavailability of same - for variable join??? Can anyone help?

From: "Greg Patnude" <gpatnude(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Repost: Syntax - or unavailability of same - for variable join??? Can anyone help?
Date: 2004-02-17 06:03:22
Message-ID: c0sasp$1m0d$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You might have better success with the form of HAVING and appropriate use of
OR IS NULL as opposed to strict JOIN and WHERE conditions...

Similar to...

SELECT A.a, B.b, C.c FROM A, B, C
HAVING (A.b = B.b OR B.b IS NULL)
GROUP BY A.b;

--
Greg Patnude / The Digital Demention
2916 East Upper Hayden Lake Road
Hayden Lake, ID 83835
(208) 762-0762

"Ben" <reply(at)to-the-newsgroup(dot)com> wrote in message
news:4c4c5dc750469f3b777c4f42ba9c0505(at)news(dot)teranews(dot)com(dot)(dot)(dot)
> I want to say:
>
> SELECT tableA.stuff,tableB.morestuff,tableC.stillmorestuff
> FROM tableA,
> LEFT OUTER JOIN tableB ON (AB match conditions)
> LEFT OUTER JOIN tableC ON (AC match conditions)
> WHERE etc
>
> However, in some cases, tableB does not have rows where the other two do
> (it contains credit card records... but when an order is paid by check,
there is
> no record.)
>
> What happens with the above syntax is I don't get a row at all.
>
> Is there a way to say that if tableB has no row, I get blank columns?
>
> Maybe I'm just looking at the wrong, but I can't seem to find out how, or
> if, one can do this.
>
> Thanks for any input.
>
> --Ben
>
>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brendan Jurd 2004-02-17 08:20:23 psql, 7.4, and the \d command
Previous Message Tom Lane 2004-02-17 02:48:23 Re: Cascade delete triggers change user credentials