pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Glenn Davy <glenn@tangelosoftware.net>
To: pgsql-novice@postgresql.org
Subject: Re: another simple SQL question
Date: Tue, 26 Jun 2007 02:02:46 +1000
Message-ID: <200706260202.46681.glenn@tangelosoftware.net> (raw)
In-Reply-To: <467FDF28.8000108@joshuaneil.com>
References: <467FDF28.8000108@joshuaneil.com>

On Tue, 26 Jun 2007 01:28:40 am 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.
>

update yourtable set firstname= substring(fullname,1,position(',' in 
fullname)-1) ,lastname= substring(fullname, position(', ' in fullname)+2, 
char_length(fullname));

glenn

> THANKS!
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend



view thread (8+ messages)  latest in thread

Message-ID: <200706260202.46681.glenn@tangelosoftware.net>
Permalink:  ../200706260202.46681.glenn@tangelosoftware.net/
Also on:    postgresql.org/message-id/200706260202.46681.glenn@tangelosoftware.net

 · 

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: glenn@tangelosoftware.net, pgsql-novice@postgresql.org
  Subject: Re: another simple SQL question
  In-Reply-To: <200706260202.46681.glenn@tangelosoftware.net>

* 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