Re: Update Join Query

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Daniel Futerman <daniel(dot)futerman(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Update Join Query
Date: 2008-06-23 23:35:47
Message-ID: 48603353.4020006@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ian Meyer 2008-06-23 23:48:38 Re: Method to detect certain characters in column?
Previous Message Steve Atkins 2008-06-23 23:28:12 Re: Method to detect certain characters in column?