Re: Outer Joins - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Outer Joins
Date
Msg-id 3A004C68.C0F5758C@agliodbs.com
Whole thread Raw
In response to Outer Joins  ("Marc Rohloff" <Marc.Rohloff@eskom.co.za>)
List pgsql-sql
Marc,

> select a.col1, b.col2 from a,b
> where a.col1 = b.col2
>    or  b.col2 is null

The above would select each record in a that matched a record in b, plus
each record in b for every possible a where b.col2 was null - not where
there was no match.

> select a.col1, b.col2 from a,b
> where a.col1 = b.col2
>    or  a.col1 not in (select b.col2 from b)

This would work, but it would be *much* slower than a UNION query.  "Not
In" queries are perhaps the slowest you can run; see the earlier thread
"Query Problem" for a discussion.  UNION queries are, in fact, very fast
... just awkward to code and manipulate.
                -Josh

-- 
______AGLIO DATABASE SOLUTIONS___________________________                                       Josh Berkus  Complete
informationtechnology      josh@agliodbs.com   and data management solutions       (415) 436-9166  for law firms, small
businesses      fax  436-0137   and non-profit organizations.       pager 338-4078                               San
Francisco


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: [GENERAL] Problem with coalesce..
Next
From: Petter Reinholdtsen
Date:
Subject: Timespan / interval calculations?