Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 4924C9FB985 for ; Mon, 25 Jun 2007 15:05:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 01346-04 for ; Mon, 25 Jun 2007 15:05:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from raptor.webhostserver.biz (raptor.webhostserver.biz [208.101.26.91]) by postgresql.org (Postfix) with ESMTP id 335489FB400 for ; Mon, 25 Jun 2007 15:05:03 -0300 (ADT) Received: from 74-134-94-223.dhcp.insightbb.com ([74.134.94.223] helo=[192.168.2.104]) by raptor.webhostserver.biz with esmtp (Exim 4.66) (envelope-from ) id 1I2svt-0002W1-3g for pgsql-sql@postgresql.org; Mon, 25 Jun 2007 12:05:01 -0600 From: manchicken Organization: notsosoft.net To: pgsql-sql@postgresql.org Subject: Re: yet another simple SQL question Date: Mon, 25 Jun 2007 12:59:34 -0500 User-Agent: KMail/1.9.7 References: <467FFEF9.5050603@joshuaneil.com> In-Reply-To: <467FFEF9.5050603@joshuaneil.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200706251259.35273.manchicken@notsosoft.net> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - raptor.webhostserver.biz X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - notsosoft.net X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/201 X-Sequence-Number: 28691 On Monday 25 June 2007 12:44:25 Joshua wrote: > 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 > ----------------- > 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 > > Thanks again for all of your help today. Everything you guys have been > sending has produced successful results. > > Thanks. > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq Well, the simple way I could think of to do this would to be a simple regex (the query mock-up below is untested)... select regexp_replace(COLUMN, '(.*)\\s\\w$', '\\1', 'g') ... This doesn't seem like a difficult thing to do in application code. It seems like it makes more sense to do it there. -- ~ manchicken <>< (A)bort, (R)etry, (I)nfluence with large hammer. 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html