From: Bryce Nesbitt <bryce1@obviously.com>
To: pgsql-sql@postgresql.org
Subject: Re: How to copy data between joined columns?
Date: Fri, 07 Apr 2006 15:24:13 -0700
Message-ID: <4436E68D.6090207@obviously.com> (raw)
In-Reply-To: <17020.1144446846@sss.pgh.pa.us>
References: <4436CC56.3040707@obviously.com>
<1144442088.32269.31.camel@state.g2switchworks.com>
<4436DB41.2070303@obviously.com>
<17020.1144446846@sss.pgh.pa.us>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Tom Lane wrote:
<blockquote cite="mid17020.1144446846@sss.pgh.pa.us" type="cite">
<pre wrap="">Bryce Nesbitt <a class="moz-txt-link-rfc2396E" href="mailto:bryce1@obviously.com"><bryce1@obviously.com></a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap=""><!---->
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.
</pre>
</blockquote>
That's great, and will work for me. But I do have the multiple match
issue. Can you also give a sub-select example for the archives?
Something robust that works against any combination of join partners
would be really useful.<br>
<br>
<pre class="moz-signature" cols="60">--
----
Visit <a href="http://www.obviously.com/">http://www.obviously.com/</a;
</pre>
</body>
</html>
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: bryce1@obviously.com
Subject: Re: How to copy data between joined columns?
In-Reply-To: <4436E68D.6090207@obviously.com>
* 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