Обсуждение: how to replace
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 ? Thanks a lot Michael
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
Michael, You practically solved it yourself in the subject of the email ;)
select replace('abcd','b','') from your_table;
Hope that helps, Anthony
-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of "Michael Höller"
Sent: Thursday, September 08, 2005 5:25 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] how to replace
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 ?
Thanks a lot
Michael
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to
majordomo@postgresql.orgso that your message can get through to the mailing list cleanly
am 08.09.2005, um 23:25:05 +0200 mailte "Michael Höller" folgendes: > Hello, > > I initially thought this is simple.. I want to relpace a character to > nothing. Eg. relace "B" to "" -> ABCD to ACD. In the new version 8.1 there are a regex_replace() - function. A other solution: write your own function with plperl. Regards, Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47212, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net=== Schollglas Unternehmensgruppe ===