pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel T. Staal <DStaal@usa.net>
To: pgsql-novice@postgresql.org
Subject: Re: another simple SQL question
Date: Mon, 25 Jun 2007 11:44:20 -0400 (EDT)
Message-ID: <58669.63.172.115.138.1182786260.squirrel@MageHandbook.com> (raw)
In-Reply-To: <467FDF28.8000108@joshuaneil.com>
References: <467FDF28.8000108@joshuaneil.com>


On Mon, June 25, 2007 11:28 am, Joshua said:
> 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.

The best way to handle this would actually be to break it _before_ putting
it in to the database.  In fact, you can just have the first and last name
fields then and get the 'fullname' from combining the two.  (Assuming you
don't care about middle names, appliations, or the anything else.)

That's just a comment: I don't know what stage you are in on this database
project.

Assuming you have the database and need to work with it my response to the
above would be to write a perl script to go through and populate the first
and last name fields.  There may be an easier way though.

Daniel T. staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------




view thread (8+ messages)  latest in thread

Message-ID: <58669.63.172.115.138.1182786260.squirrel@MageHandbook.com>
Permalink:  ../58669.63.172.115.138.1182786260.squirrel@MageHandbook.com/
Also on:    postgresql.org/message-id/58669.63.172.115.138.1182786260.squirrel@MageHandbook.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: DStaal@usa.net, pgsql-novice@postgresql.org
  Subject: Re: another simple SQL question
  In-Reply-To: <58669.63.172.115.138.1182786260.squirrel@MageHandbook.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