From: Bruno Wolff III <bruno@wolff.to>
To: MichaelHoeller@t-online.de
Cc: pgsql-sql@postgresql.org
Subject: Re: how to update with a join?
Date: Sat, 10 Sep 2005 13:03:52 -0500
Message-ID: <20050910180352.GC11142@wolff.to> (raw)
In-Reply-To: <200509101856.10905.MichaelHoeller@t-online.de>
References: <200509101847.48765.MichaelHoeller@t-online.de>
<200509101856.10905.MichaelHoeller@t-online.de>
On Sat, Sep 10, 2005 at 18:56:10 +0200,
MichaelHoeller@t-online.de wrote:
> 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.
You can use 'FROM' in an update statement to include other tables.
For example (doing a pointless self join):
UPDATE stamm
SET code = replace (code, 'k' , '')
FROM stamm a
WHERE a.code = code
;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, MichaelHoeller@t-online.de
Subject: Re: how to update with a join?
In-Reply-To: <20050910180352.GC11142@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox