X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 66A08D1D1CD for ; Wed, 4 Feb 2004 16:45:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54192-03 for ; Wed, 4 Feb 2004 12:45:41 -0400 (AST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.173]) by svr1.postgresql.org (Postfix) with ESMTP id 12675D1D87A for ; Wed, 4 Feb 2004 12:45:42 -0400 (AST) Received: from [212.227.126.208] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1AoQ9l-0001bg-00 for pgsql-sql@postgresql.org; Wed, 04 Feb 2004 17:45:41 +0100 Received: from [80.128.76.238] (helo=FRITZweb) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1AoQ9l-0004G9-00 for pgsql-sql@postgresql.org; Wed, 04 Feb 2004 17:45:41 +0100 From: =?iso-8859-1?Q?J=FCrgen_Cappel?= To: "pgsql-sql" Subject: Update from same table Date: Wed, 4 Feb 2004 17:46:19 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:18ffa34e0aa20c651c9363a5f5f711d8 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/45 X-Sequence-Number: 16736 Hello, I want to update columns in a table that match a fixed key from the same column of the same table matching another fixed key. There can be several tuples per key distinguished by a secondary id. Tuples are unique with the combined keys. Maybe a query could look something like this: UPDATE a.mytable from b.mytable SET a.mycolumn = b.mycolumn WHERE a.firstid = some_key AND b.firstid = some_other_key AND a.secondaryid = b.secondaryid; But it's a syntax error. I tried a subselect but i'm failing to connect the subselect's 2nd ID with the update's 2nd ID. Any help ? Thanks, Jürgen