Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Need help on SQL

Re: Need help on SQL

From: TurkBear <noone_at_nowhere.com>
Date: Tue, 01 May 2001 08:54:10 -0500
Message-ID: <mfftet4cvb0nl6q2q28fqa9gb3jlcirlqt@4ax.com>

No, don't look for POS, look for INSTR -( and SUBSTR) If name_field = 'Green,Joe) then
last_name = substr(name_field,1,Instr(name_field,',') -1 ) [ the -1 is because the instr returns the position of the comma and you want everything before that, but not the comma itself.] first_name = substr(name_field,instr(name_field,',')+1) [ This gets everything from 1 place past the comma to the end...]

Real world note:

I hope your data is ' cleaner' than mine in reality since I have to test for middle names and middle initials...Its not fun sometimes... My real-life data has a name field which is Lastname,first_name, middlesomething)
e.g.
That can be
Smith,Joe
Smith,Joe Louis
Smith Joe Jr.
Smith Joe L.

Good luck...

"Stefan Grundmann" <s.grundmann_at_t-online.de> wrote:

>Hallo Eric!
>
>Look for POS.
>
>Stefan.
>
>
>Eric Pearson <eric.pearson_at_ssss.gouv.qc.ca> schrieb in im Newsbeitrag:
>4vyH6.52$k95.20033_at_news20.bellglobal.com...
>> Hi, i have a field names nom_concat, in it I store the name of employes in
>> this format: Pearson, Eric
>> it's varchar2(32)
>>
>> I would like to easily separate the first and last name so I can put them
 in
>> two different field named first_name and last_name (both are varchar2(15))
>>
>> I tried with LTRIM and RTRIM but it doesn't work the way I would like it
 to.
>> Is there an SQL function that takes all the characters in a string until
 it
>> meets a character that I give it i.e. a comma
>>
>> thanks
>>
>> Eric Pearson
>> eric.pearson_at_ssss.gouv.qc.ca
>>
>>
>
Received on Tue May 01 2001 - 08:54:10 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US