Re: Why doesn't update syntax match insert syntax?

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема Re: Why doesn't update syntax match insert syntax?
Дата
Msg-id B6F6FD62F2624C4C9916AC0175D56D880CE2A703@jenmbs01.ad.intershop.net
обсуждение исходный текст
Ответ на Re: Why doesn't update syntax match insert syntax?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
> On Thu, Oct 10, 2013 at 10:03 AM, Rob Richardson
> <RDRichardson@rad-con.com> wrote:
>
> > UPDATE inner_covers
> > SET X = (SELECT sl.X FROM storage_locations sl where sl.name = inner_covers.name),
> > Y = (SELECT sl.Y FROM storage_locations sl where sl.name = inner_covers.name)
> >
> > Or is there another, more convenient form of the UPDATE query that I'm not familiar with?
> >
> > Thanks very much!
>
> you have UPDATE FROM:
>
> UPDATE foo SET a=bar.a, b=bar.b
> FROM bar WHERE foo.id = bar.id;
>
> merlin

Hi,

an alternate syntax which is nearer to the INSERT one:

update foo set (a,b) = (bar.a, bar.b)
FROM bar
WHERE foo.id = bar.id;

I guess this is just a question of taste...

regards,

Marc Mamin

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

Предыдущее
От: David Johnston
Дата:
Сообщение: Re: Can a view represent a schedule for all days into the future?
Следующее
От: Adam Mackler
Дата:
Сообщение: Re: Can a view represent a schedule for all days into the future?