Search Postgresql Archives

Re: "INNER JOIN .... USING " in an UPDATE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux