Re: correlated delete with 'in' and 'left outer join'

Поиск
Список
Период
Сортировка
От Michael Chaney
Тема Re: correlated delete with 'in' and 'left outer join'
Дата
Msg-id 20040227170110.GA7898@michaelchaney.com
обсуждение исходный текст
Ответ на Re: correlated delete with 'in' and 'left outer join'  (Mike Mascari <mascarm@mascari.com>)
Ответы Re: correlated delete with 'in' and 'left outer join'  (Mike Mascari <mascarm@mascari.com>)
Список pgsql-general
> >The original subquery looked like:
> >select distinct e.ItemID from LogEvent e left outer join Item i
> >on e.ItemID = i.ItemID where e.EventType != 'i' and i.ItemID is null

Please, before continuing this thread, read my post below.  What you're
all getting around to, albeit painfully, is that this subquery is
worthless as-is.  This is the mysql way of finding rows in one table
with no match in another without the convenience of the "in" or "exists"
constructs.

Because we're using Postgres and have those constructs, the original
query can be rewritten simply with either:

delete from LogEvent where EventType != 'i' and ItemID not in
        (select ItemID from Item)

That's it.  That's the whole query.  It does what he wants.

Michael
--
Michael Darrin Chaney
mdchaney@michaelchaney.com
http://www.michaelchaney.com/

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

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: field must appear in the GROUP BY clause or be used
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: field must appear in the GROUP BY clause or be used