From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bryce Nesbitt <bryce1@obviously.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to copy data between joined columns?
Date: Fri, 07 Apr 2006 17:54:06 -0400
Message-ID: <17020.1144446846@sss.pgh.pa.us> (raw)
In-Reply-To: <4436DB41.2070303@obviously.com>
References: <4436CC56.3040707@obviously.com>
<1144442088.32269.31.camel@state.g2switchworks.com>
<4436DB41.2070303@obviously.com>
Bryce Nesbitt <bryce1@obviously.com> writes:
> If it were for the same rows in the same table, I would not have asked.
> This is for columns from two tables, whos relationship is only
> meaningful after a join.
You have to write out the join condition longhand, eg
UPDATE targettable SET targcol = srccol
FROM srctable
WHERE joincol1 = joincol2;
This can be tricky, particularly if there might be more than one source
row joining to a given target row. (IIRC, the effective behavior is
that any given target row's update will occur against a random one of
the possible join partners.) A lot of people prefer to code it using
sub-selects.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, bryce1@obviously.com
Subject: Re: How to copy data between joined columns?
In-Reply-To: <17020.1144446846@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox