Re: Complex Update Queries with Fromlist

Поиск
Список
Период
Сортировка
От Mark Dexter
Тема Re: Complex Update Queries with Fromlist
Дата
Msg-id 5E8F9F5B63726C48836757FE673B584E010EE284@dcimail.dexterchaney.local
обсуждение исходный текст
Ответ на Complex Update Queries with Fromlist  ("Mark Dexter" <MDEXTER@dexterchaney.com>)
Список pgsql-general
Thank you.  That works for the simple example I had.

However, I have an additional question about this.  What if I need to do
a LEFT OUTER JOIN in the Fromlist.  For example, this query works but it
requires the orders table to appear twice.

UPDATE orders set requireddate =
  (case when c.city in ('Seattle','Portland') then date(o.OrderDate) + 1

    else date(o.OrderDate) + 2 end)
FROM orders o
LEFT OUTER JOIN customers c on
  o.customerid = c.customerid
  where c.region in ('WA','OR')
 and orders.orderid = o.orderid

Is there some way to do an outer join in the Fromlist back to the main
table being updated without having it appear twice?  Thanks.


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

Предыдущее
От: Josh Close
Дата:
Сообщение: Re: plpgsql loop not returning value
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Avoiding sequential scans with OR join condition