Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 85AB59FB5AE; Tue, 26 Jun 2007 04:14:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 04174-04; Tue, 26 Jun 2007 04:14:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from interscan.indicator.com (mail.indicator.be [193.121.199.3]) by postgresql.org (Postfix) with ESMTP id A82169FB595; Tue, 26 Jun 2007 04:14:30 -0300 (ADT) Received: from webaccess.indicator.be ([10.100.1.7]) by interscan.indicator.com with InterScan Message Security Suite; Tue, 26 Jun 2007 08:59:03 +0200 Received: from DOMEXT-MTA by webaccess.indicator.bewith Novell_GroupWise; Tue, 26 Jun 2007 09:14:28 +0200 Message-Id: <4680D8E8.A3DD.0030.0@indicator.be> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Tue, 26 Jun 2007 09:14:17 +0200 From: "Bart Degryse" To: , Subject: Re: yet another simple SQL question References: <467FFEF9.5050603@joshuaneil.com><20070625180717.GA19814@a-krets chmer.de> In-Reply-To: <20070625180717.GA19814@a-kretschmer.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__PartCBEC00D9.0__=" X-imss-version: 2.047 X-imss-result: Passed X-imss-approveListMatch: *@indicator.be X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.213 tagged_above=0 required=5 tests=AWL=0.261, BAYES_40=-0.185, FORGED_RCVD_HELO=0.135, HTML_MESSAGE=0.001, UNPARSEABLE_RELAY=0.001 X-Spam-Level: X-Archive-Number: 200706/210 X-Sequence-Number: 28700 --=__PartCBEC00D9.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable >>>> "A. Kretschmer" 2007-06-25 20:07 = >>> >am Mon, dem 25.06.2007, um 12:44:25 -0500 mailte Joshua folgendes: >> Ok, >>=20 >> You guys must be getting sick of these newbie questions, but I can't=20 >> resist since I am learning a lot from these email lists and getting=20 >> results quick! Thanks to everyone for their contributions. >>=20 >> Here is my questions.... >>=20 >> I have a column that looks like this >>=20 >> firstname >> ----------------- >> John B >> Mark A >> Jennifer D >>=20 >> Basically I have the first name followed by a middle initial. Is there = a=20 >> quick command I can run to strip the middle initial? Basically, I = just=20 >> need to delete the middle initial so the column would then look like = the=20 >> following: >>=20 >> firstname >> --------------- >> John >> Mark >> Jennifer > >Yes, of course: > >test=3D# select split_part('My Name', ' ', 1); >split_part >------------ >My >(1 row) > >And now, i think, you should read our fine manual: >http://www.postgresql.org/docs/current/interactive/=20 > >Andreas While there are several ways to make the split the result will never be = good. As someone responded before: this is multicultural. You can never garantee that the = first name stops at the=20 first space. What about names like Sue Ellen or Pieter Jan. I know people = with those names and none of them would like to be calles Sue or Pieter and right they are. = Simply because their first name doesn't stop at the first space. In many countries the concept = of 'middle initials' is meaningless because no one ever uses it. In my (humble) opinion there are two roads to walk. Either you get your = data from the 'client'=20 split up to the level of detail you require, if someone knows it's = him/her. Or you use the data as is and you don't split it up. --=__PartCBEC00D9.0__= Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Description: HTML


>>>> "A. Kretschmer" <andreas.kretschmer@scholl= glas.com> 2007-06-25 20:07 >>>
>am  Mon, dem = 25.06.2007, um 12:44:25 -0500 mailte Joshua folgendes:
>> = Ok,
>>
>> You guys must be getting sick of these newbie = questions, but I can't
>> resist since I am learning a lot from = these email lists and getting
>> results quick! Thanks to = everyone for their contributions.
>>
>> Here is my = questions....
>>
>> I have a column that looks like = this
>>
>> firstname
>> -----------------
&g= t;> John B
>> Mark A
>> Jennifer D
>> =
>> Basically I have the first name followed by a middle initial. = Is there a
>> quick command I can run to strip the middle = initial? Basically, I just
>> need to delete the middle initial = so the column would then look like the
>> following:
>> =
>> firstname
>> ---------------
>> John
>= > Mark
>> Jennifer
>
>Yes, of course:
>
&g= t;test=3D# select split_part('My Name', ' ', 1);
>split_part
>-= -----------
>My
>(1 row)
>
>And now, i think, you = should read our fine manual:
>http://www.postgresql.org/docs/current/interactive= /
>
>Andreas
While there are several ways to make the split the result will never = be good. As someone
responded before: this is multicultural. You can never garantee that = the first name stops at the
first space. What about names like Sue Ellen or Pieter Jan. I know = people with those names
and none of them would like to be calles Sue or Pieter and right they = are. Simply because their
first name doesn't stop at the first space. In many countries the = concept of 'middle initials' is
meaningless because no one ever uses it.
In my (humble) opinion there are two roads to walk. Either you get = your data from the 'client'
split up to the level of detail you require, if someone knows it's = him/her. Or you use the data
as is and you don't split it up.
--=__PartCBEC00D9.0__=--