Re: another simple SQL question - Mailing list pgsql-novice

From Derrick Betts
Subject Re: another simple SQL question
Date
Msg-id 467FE784.3060606@blueaxis.com
Whole thread Raw
In response to another simple SQL question  (Joshua <joshua@joshuaneil.com>)
Responses Re: another simple SQL question  (Glenn Davy <glenn@tangelosoftware.net>)
List pgsql-novice
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
>
>
>



pgsql-novice by date:

Previous
From: Glenn Davy
Date:
Subject: Re: another simple SQL question
Next
From: Glenn Davy
Date:
Subject: Re: another simple SQL question