Re: Update Join Query - Mailing list pgsql-general

From Craig Ringer
Subject Re: Update Join Query
Date
Msg-id 48603353.4020006@postnewspapers.com.au
Whole thread Raw
In response to Update Join Query  ("Daniel Futerman" <daniel.futerman@gmail.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: Method to detect certain characters in column?
Next
From: "Ian Meyer"
Date:
Subject: Re: Method to detect certain characters in column?