X-Original-To: pgsql-php@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7594F477631 for ; Thu, 30 Jan 2003 17:21:08 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 86BA4477583 for ; Thu, 30 Jan 2003 17:21:02 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.6/8.12.6) with ESMTP id h0UJcXoV000853; Thu, 30 Jan 2003 12:38:35 -0700 (MST) Date: Thu, 30 Jan 2003 12:33:29 -0700 (MST) From: "scott.marlowe" To: Matthew Horoschun Cc: ryanne cruz , "\\\"pgsql-php@postgresql.org\\\"" Subject: Re: underscore In-Reply-To: <1E50BE38-3411-11D7-9306-000393B3A702@canprint.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/97 X-Sequence-Number: 1842 On Thu, 30 Jan 2003, Matthew Horoschun wrote: > Hi Ryanne, > > On Thursday, January 30, 2003, at 04:09 PM, ryanne cruz wrote: > > > i have a column wherein a lot of entries has 2 or more names int it. > > these are > > separated by spaces. an example is: "John Doe", "Mary Margaret Smith". > > i need > > to replace the spaces with an underscore. any idea how to do this? > > > In PHP use preg_replace (http://php.net/preg_replace for details) > > In PostgreSQL use replace(string text, from text, to text) > > (http://www.postgresql.org/docs/ > view.php?version=7.3&idoc=1&file=functions-string.html) > > To update a column in a table, you could do something like: > > UPDATE table SET column = REPLACE( column, ' ', '_' ); For something like this str_replace is easier to use and generally faster.