Re: another simple SQL question

From: "Daniel T(dot) Staal" <DStaal(at)usa(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: another simple SQL question
Date: 2007-06-25 15:44:20
Message-ID: 58669.63.172.115.138.1182786260.squirrel@MageHandbook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql


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.
---------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message gary jefferson 2007-06-25 15:47:06 Re: dynamic table/col names in plpgsql
Previous Message Nicholas Barr 2007-06-25 15:44:01 Re: Move a database from one server to other

Browse pgsql-novice by date

  From Date Subject
Next Message Glenn Davy 2007-06-25 16:02:46 Re: another simple SQL question
Previous Message Nicholas Barr 2007-06-25 15:41:02 Re: another simple SQL question

Browse pgsql-sql by date

  From Date Subject
Next Message Glenn Davy 2007-06-25 16:02:46 Re: another simple SQL question
Previous Message Nicholas Barr 2007-06-25 15:41:02 Re: another simple SQL question