Re: How to copy data between joined columns?

From: Bryce Nesbitt <bryce1(at)obviously(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to copy data between joined columns?
Date: 2006-04-07 22:24:13
Message-ID: 4436E68D.6090207@obviously.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!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(dot)1144446846(at)sss(dot)pgh(dot)pa(dot)us" type="cite">
<pre wrap="">Bryce Nesbitt <a class="moz-txt-link-rfc2396E" href="mailto:bryce1(at)obviously(dot)com">&lt;bryce1(at)obviously(dot)com&gt;</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.&nbsp; But I do have the multiple match
issue.&nbsp; Can you also give a sub-select example for the archives?&nbsp;
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>

Attachment Content-Type Size
unknown_filename text/html 1.5 KB

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Keith Hutchison 2006-04-08 21:10:38 Returning a set from an function
Previous Message Tom Lane 2006-04-07 21:54:06 Re: How to copy data between joined columns?