X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DE47CD8997 for ; Sat, 10 Sep 2005 13:56:40 -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 51877-03 for ; Sat, 10 Sep 2005 16:56:37 +0000 (GMT) Received: from mailout06.sul.t-online.com (mailout06.sul.t-online.com [194.25.134.19]) by svr1.postgresql.org (Postfix) with ESMTP id 37BF3D89B6 for ; Sat, 10 Sep 2005 13:56:36 -0300 (ADT) Received: from fwd35.aul.t-online.de by mailout06.sul.t-online.com with smtp id 1EE8ea-0002jO-02; Sat, 10 Sep 2005 18:56:36 +0200 Received: from pD9F8CADE.dip.t-dialin.net (ESAZRsZXQej9sxvFqE05LJyH6AAiTgQf9YiTCaUuXiqPYD2+wIl2Qg@[217.248.202.222]) by fwd35.sul.t-online.de with esmtp id 1EE8eW-0biArI0; Sat, 10 Sep 2005 18:56:32 +0200 From: MichaelHoeller@t-online.de Reply-To: Michael Hoeller To: pgsql-sql@postgresql.org Subject: Re: how to update with a join? Date: Sat, 10 Sep 2005 18:56:10 +0200 User-Agent: KMail/1.7.1 References: <200509101847.48765.MichaelHoeller@t-online.de> In-Reply-To: <200509101847.48765.MichaelHoeller@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200509101856.10905.MichaelHoeller@t-online.de> X-ID: ESAZRsZXQej9sxvFqE05LJyH6AAiTgQf9YiTCaUuXiqPYD2+wIl2Qg X-TOI-MSGID: 6dd3dac5-9b28-4656-b042-3298cedab045 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.089 required=5 tests=[AWL=-0.089, NO_REAL_NAME=0.178] X-Spam-Level: X-Archive-Number: 200509/110 X-Sequence-Number: 22657 Hello all, thanks for the answere to the prev. thread. With the help of them I solved the problme I used "not like" instead of <> and this leads to a problem. This works for me: update stamm set code = replace (code, 'k' , '') where code like '%k%' and code <> '%V%'; I would still be interested to learn how to update a row when the result set is only reachable via a join. Thanks a gain Michael Michael Hoeller wrote at Samstag, 10. September 2005 18:47: > Hello > > I like to delete "k" from a string with the statement > update stamm set code = replace (code, 'k' , ''); > > But the only way to get the canditates I want to update is the > following statement. It seems that I can not update when I do a join. > > Is there a way around it? With google I found a hint that a subselect > could help but there was no exsample ... And I did not found out how > to do this. > > select a.code > from stamm a > where > a.skart in ( > (select skart > from stamm > where code like '%k%') > ) > and a.code not like '%V%'; > > I would be happy about a hint. > > Thanks a lot > Michael