Re: Outer Joins

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Outer Joins
Дата
Msg-id 3A004C68.C0F5758C@agliodbs.com
обсуждение исходный текст
Ответ на Outer Joins  ("Marc Rohloff" <Marc.Rohloff@eskom.co.za>)
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: [GENERAL] Problem with coalesce..
Следующее
От: Petter Reinholdtsen
Дата:
Сообщение: Timespan / interval calculations?