From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Webb Sprague <webb(dot)sprague(at)gmail(dot)com> |
Cc: | GENERAL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: "INNER JOIN .... USING " in an UPDATE |
Date: | 2008-11-18 08:03:01 |
Message-ID: | 492276B5.1010609@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Webb Sprague wrote:
> Hi all,
>
> (Version 3.5.5)
I'd upgrade - version 3.5.5 doesn't actually exist :-)
> I have tried to figure this out, but the docs, google, and my all
> imagination fail me. I want to use a join clause with a "using list"
> in an update statement. The following works, but it uses the WHERE
> version of a join:
>
> update new_pivoted_table a set "2008-11-10" = b.data_stuff from
> test_pivot b where a.id=b.id and a.id2=b.id2 and
> date_ex='2008-11-10';
> UPDATE 3
>
> The following doesn't work, to my chagrin:
>
> wsprague=# update new_pivoted_table a set "2008-11-10" = b.data_stuff
> from test_pivot b join a using (id, id2) where date_ex='2008-11-10';
> ERROR: relation "a" does not exist
I think you're out of luck. The UPDATE ... FROM bit is a PostgreSQL
extension in itself, the standard way to do this would be:
UPDATE t1 ... WHERE (id,id2) IN (SELECT id,id2 FROM t1 JOIN t2 USING ...)
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Christophe Arnu | 2008-11-18 08:36:29 | lesslog "incorrect resource manager data checksum." |
Previous Message | Albe Laurenz | 2008-11-18 08:02:31 | Re: pgsql-general@postgresql.org |