pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Derrick Betts <list@blueaxis.com>
To: Joshua <joshua@joshuaneil.com>
Cc: pgsql-novice@postgresql.org
Subject: Re: another simple SQL question
Date: Mon, 25 Jun 2007 10:04:20 -0600
Message-ID: <467FE784.3060606@blueaxis.com> (raw)
In-Reply-To: <467FDF28.8000108@joshuaneil.com>
References: <467FDF28.8000108@joshuaneil.com>

Try this:
SELECT substr(fullname, 1, position(',' IN fullname)-1) AS first,
   trim(substr(fullname, position(',' IN fullname)+1, length(fullname))) 
AS last
   FROM table_name;

Joshua wrote:
> Ok here is another simple question from a novice....
> 
> Here is what my table looks like
> 
> firstname         lastname         fullname
> ----------       ----------       -----------
>                                              smith, john
>                                              green, susan
>                                              white, jeff
> 
> 
> How can I break the fullname field into firstname lastname fields so it 
> looks like the following:
> 
> firstname      lastname      fullname
> ---------     ---------       ---------
> john             smith             smith, john
> susan           green             green, susan
> jeff               white             white, jeff
> 
> Please let me know. Sorry for such simple novice questions, I appreciate 
> your support.
> 
> THANKS!
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
> 
> 
> 





view thread (8+ messages)  latest in thread

Message-ID: <467FE784.3060606@blueaxis.com>
Permalink:  ../467FE784.3060606@blueaxis.com/
Also on:    postgresql.org/message-id/467FE784.3060606@blueaxis.com

 · 

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: list@blueaxis.com, joshua@joshuaneil.com, pgsql-novice@postgresql.org
  Subject: Re: another simple SQL question
  In-Reply-To: <467FE784.3060606@blueaxis.com>

* 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