Re: another simple SQL question

Поиск
Список
Период
Сортировка
От Derrick Betts
Тема Re: another simple SQL question
Дата
Msg-id 467FE784.3060606@blueaxis.com
обсуждение исходный текст
Ответ на another simple SQL question  (Joshua <joshua@joshuaneil.com>)
Ответы Re: another simple SQL question  (Glenn Davy <glenn@tangelosoftware.net>)
Список 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 по дате отправления:

Предыдущее
От: Glenn Davy
Дата:
Сообщение: Re: another simple SQL question
Следующее
От: Glenn Davy
Дата:
Сообщение: Re: another simple SQL question