Re: another simple SQL question

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

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Daniel T. Staal"
Дата:
Сообщение: Re: another simple SQL question
Следующее
От: Derrick Betts
Дата:
Сообщение: Re: another simple SQL question