pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ragnar <gnari@hive.is>
To: Joshua <joshua@joshuaneil.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: yet another simple SQL question
Date: Mon, 25 Jun 2007 18:33:14 +0000
Message-ID: <1182796394.5953.294.camel@localhost.localdomain> (raw)
In-Reply-To: <467FFEF9.5050603@joshuaneil.com>
References: <467FFEF9.5050603@joshuaneil.com>

On mán, 2007-06-25 at 12:44 -0500, Joshua wrote:
> I have a column that looks like this
> 
> firstname
> -----------------
> John B
> Mark A
> Jennifer D
> 
> Basically I have the first name followed by a middle initial. Is there a 
> quick command I can run to strip the middle initial?

how about:

  select regexp_replace(firstname,' .*','') as firstname 
  from footable;

or:

  select substring(firstname FROM '(.*) ') as firstname 
  from footable;


gnari





view thread (14+ messages)  latest in thread

Message-ID: <1182796394.5953.294.camel@localhost.localdomain>
Permalink:  ../1182796394.5953.294.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1182796394.5953.294.camel@localhost.localdomain

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gnari@hive.is, joshua@joshuaneil.com
  Subject: Re: yet another simple SQL question
  In-Reply-To: <1182796394.5953.294.camel@localhost.localdomain>

* 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