Search Postgresql Archives

Re: Update Join Query

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

 



Daniel Futerman wrote:

Is it possible to have UPDATE JOIN queries in PostgreSQL?

Yes:

UPDATE target
    ....
FROM othertable;

As far as I know Pg can only do an inner join on the update target. This can be easily be turned into an outer join with something like:

UPDATE target
   ....
FROM target t LEFT OUTER JOIN othertable
WHERE target.id = t.id;

or similar. I haven't checked to see whether this results in an extra scan in the query plan; you might want to use EXPLAIN ANALYZE to examine how Pg will execute the query.

--
Craig Ringer


[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