From: Rob Sargent <robjsargent@gmail.com>
To: Antonio Silva <aolinto.lst@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: using replace function
Date: Thu, 28 Nov 2019 14:48:07 -0800
Message-ID: <E7D20D52-5606-4D78-8CD8-77BB17DB62AA@gmail.com> (raw)
In-Reply-To: <CAE8g1gN26kaDGRvcRVr+gRgeySYmroswtCG0ZyCL2gFwsizJcg@mail.gmail.com>
References: <CAE8g1gN26kaDGRvcRVr+gRgeySYmroswtCG0ZyCL2gFwsizJcg@mail.gmail.com>
> On Nov 28, 2019, at 1:09 PM, Antonio Silva <aolinto.lst@gmail.com> wrote:
>
> Hello list
>
> I want to replace a string (not a substring) in a field but making sure that the string in the full field.
>
> In the example below since 'blue' is not the full text in 'blue shark' there should not have a replacement.
>
> How to say "replace only with 'blue' if it is the full string in the field".
>
> With REPLACE I get:
>
> SELECT REPLACE('blue shark','blue','blue fish');
> replace
> -----------------
> blue fish shark
> (1 row)
>
> but I would like to get:
>
> SELECT REPLACE('blue shark','blue','blue fish');
> replace
> ------------
> blue shark
> (1 row)
>
> Thanks a lot
>
> Antonio Olinto
does this help?
select replace (a.col, ‘value’, ’new value’) where a.col = ‘value’;
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com, aolinto.lst@gmail.com
Subject: Re: using replace function
In-Reply-To: <E7D20D52-5606-4D78-8CD8-77BB17DB62AA@gmail.com>
References: <CAE8g1gN26kaDGRvcRVr+gRgeySYmroswtCG0ZyCL2gFwsizJcg@mail.gmail.com> <E7D20D52-5606-4D78-8CD8-77BB17DB62AA@gmail.com>
* 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