Re: outer joins

From: "Jason Minion" <jason(dot)minion(at)sigler(dot)com>
To: "D Kavan" <bitsandbytes88(at)hotmail(dot)com>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: outer joins
Date: 2005-08-05 20:14:20
Message-ID: 0105A1BF505D304E9E5AF38B63E40E4E69D3D8@EXCHANGE.siglercompanies.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

If he's using a restriction upon an outer joined table in the where clause
it might be returning results like it was an inner join, ie:

select * from A left outer join B on A.id=B.id
where B.accessed>'2005-10-31';

Instead you'd want to check for the outer joined field having a null
value in the where clause, or move that restriction up to the on clause:

select * from A left outer join B
on A.id=B.id AND B.accessed>'2005-10-31';

or

select * from A left outer join B
on A.id=B.id
where (B.accessed IS NULL OR B.accessed>'2005-10-31');

I assure you, outer joins work just fine on PostgreSQL.

Jason

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org]On Behalf Of D Kavan
Sent: Friday, August 05, 2005 2:55 PM
To: pgsql-admin(at)postgresql(dot)org
Subject: [ADMIN] outer joins

Hi,

One the developers is saying that he can't do outer joins on postgresql.
Is this true? We have postgresql 8.02.

He is using this syntax:
select from A left outer join b on A.id=B.id;

This processes but comes back with a result like it was an inner join.

~DjK

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Michael Fuhr 2005-08-05 20:22:46 Re: outer joins
Previous Message D Kavan 2005-08-05 19:55:16 outer joins