X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id BE39511F678B for ; Fri, 7 Apr 2006 19:24:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85096-02 for ; Fri, 7 Apr 2006 19:24:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from outbound7.internet-mail-service.net (outbound7.internet-mail-service.net [216.240.47.198]) by postgresql.org (Postfix) with ESMTP id 0544511F65E8 for ; Fri, 7 Apr 2006 19:24:21 -0300 (ADT) Received: from idiom.com (idiom.com [216.240.32.1]) by outbound.internet-mail-service.net (Postfix) with ESMTP id 78D4B24AB75 for ; Fri, 7 Apr 2006 15:24:21 -0700 (PDT) Received: from [192.168.1.109] (adsl-69-107-132-69.dsl.pltn13.pacbell.net [69.107.132.69]) by idiom.com (8.12.11/8.12.11) with ESMTP id k37MOLNA060932 for ; Fri, 7 Apr 2006 15:24:21 -0700 (PDT) (envelope-from bryce1@obviously.com) Message-ID: <4436E68D.6090207@obviously.com> Date: Fri, 07 Apr 2006 15:24:13 -0700 From: Bryce Nesbitt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: How to copy data between joined columns? References: <4436CC56.3040707@obviously.com> <1144442088.32269.31.camel@state.g2switchworks.com> <4436DB41.2070303@obviously.com> <17020.1144446846@sss.pgh.pa.us> In-Reply-To: <17020.1144446846@sss.pgh.pa.us> Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.119, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.001] X-Spam-Score: 0.121 X-Spam-Level: X-Archive-Number: 200604/57 X-Sequence-Number: 24866 Tom Lane wrote:
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.
  
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.

-- 
----
Visit http://www.obviously.com/