Re: how to replace - Mailing list pgsql-sql

From Owen Jacobson
Subject Re: how to replace
Date
Msg-id 144D12D7DD4EC04F99241498BB4EEDCC08B412@nelson.osl.com
Whole thread Raw
In response to how to replace  ("Michael Höller" <MichaelHoeller@t-online.de>)
List pgsql-sql
Michael Höller wrote:

> Hello,
>
> I initially thought this is simple.. I want to relpace a character to
> nothing. Eg. relace "B" to "" ->  ABCD to ACD.
>
> All me approches vaild but I am sure that I have seen it already and
> think it was not tricky..
>
> Can someone please help me ?

From the manual:

replace(string text, from text, to text) returns text Replace all occurrences in string of substring from with
substringto. 

<http://www.postgresql.org/docs/8.0/interactive/functions-string.html>

To replace only on output, for example:

SELECT replace (sometextcolumn, from 'B', to '') FROM sometable;

To replace the data,

UPDATE sometable SET sometextcolumn = replace (sometextcolumn, from 'B', to '');

HTH,
Owen


pgsql-sql by date:

Previous
From: "Michael Höller"
Date:
Subject: how to replace
Next
From: "Anthony Molinaro"
Date:
Subject: Re: how to replace