X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1AC565283F for ; Wed, 15 Jun 2005 11:34:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 14244-03 for ; Wed, 15 Jun 2005 14:34:41 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id DAEB352835 for ; Wed, 15 Jun 2005 11:34:40 -0300 (ADT) Received: (qmail 8567 invoked by uid 500); 15 Jun 2005 14:34:16 -0000 Date: Wed, 15 Jun 2005 09:34:16 -0500 From: Bruno Wolff III To: Praveen Raja Cc: 'Bruno =?iso-8859-1?Q?Pr=E9vost'?= , pgsql-sql@postgresql.org Subject: Re: update syntax Message-ID: <20050615143416.GD7595@wolff.to> Mail-Followup-To: Bruno Wolff III , Praveen Raja , 'Bruno =?iso-8859-1?Q?Pr=E9vost'?= , pgsql-sql@postgresql.org References: <006b01c571a4$dbbb7d40$5d00a8c0@BRUNO2500> <003001c571a6$c337a1c0$4c0ca8c0@sek.se> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <003001c571a6$c337a1c0$4c0ca8c0@sek.se> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/172 X-Sequence-Number: 21773 On Wed, Jun 15, 2005 at 14:35:42 +0200, Praveen Raja wrote: > Thanks. The UPDATE works ok now. But using the same logic it doesn’t > seem possible to delete rows. Is this also possible? Yes. When you use table names in the where clause they are automatically added to the join list if they aren't list in the from item list. For 8.1 this will be changing. There will be a USING clause on DELETE statements that can be used to list extra tables and the implied from feature will be disabled by default. > > Try something like this > > > > UPDATE table1 > SET col1 = b.col1 > FROM table1 b > WHERE table1.col2 = b.col2 and > table1.col3 = ‘something’ and > b.col3 = ‘somethingelse’