Re: yet another simple SQL question

From: Ragnar <gnari(at)hive(dot)is>
To: Joshua <joshua(at)joshuaneil(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: yet another simple SQL question
Date: 2007-06-25 18:33:14
Message-ID: 1182796394.5953.294.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2007-06-25 18:42:48 Standby servers and incrementally updated backups
Previous Message Magnus Hagander 2007-06-25 18:20:29 Re: Automatic install on windows

Browse pgsql-novice by date

  From Date Subject
Next Message Erik Jones 2007-06-25 19:03:58 Re: yet another simple SQL question
Previous Message A. Kretschmer 2007-06-25 18:07:17 Re: [SQL] yet another simple SQL question

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Jones 2007-06-25 19:03:58 Re: yet another simple SQL question
Previous Message A. Kretschmer 2007-06-25 18:07:17 Re: [SQL] yet another simple SQL question