Re: find the "missing" rows

Поиск
Список
Период
Сортировка
От Andrew - Supernews
Тема Re: find the "missing" rows
Дата
Msg-id slrncqtqbo.2kf6.andrew+nonews@trinity.supernews.net
обсуждение исходный текст
Ответ на find the "missing" rows  ("Kevin B." <db@ke5in.com>)
Список pgsql-sql
On 2004-12-02, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Kevin B." <db@ke5in.com> writes:
>> Select a.i, b.i
>> from t as a
>> left join t as b on a.i = b.i
>> where a.n = 'a' and b.n = 'b' and b.i is null
>
> This can't succeed since the b.n = 'b' condition is guaranteed to fail
> when b.* is nulled out ...

You can make it work by moving parts of the condition into the explicit
join clause:

select a.i from t as a left join t as b on a.n='a' and b.n='b' and a.i=b.i where a.n='a' and b.i is null; 

(notice you still need the check on a.n='a' outside the join condition)

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services


В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: order by problem
Следующее
От: Andrew M
Дата:
Сообщение: Failed system call was shmget(key=1, size=1155072, 03600).