Search Postgresql Archives

Re: using replace function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Nov 28, 2019, at 1:09 PM, Antonio Silva <aolinto.lst@xxxxxxxxx> 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’;







[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux