Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id E035A9FBA7D for ; Mon, 25 Jun 2007 15:17:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 61592-07 for ; Mon, 25 Jun 2007 15:17:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mx1.ipf.is (mack.ipf.is [85.197.192.164]) by postgresql.org (Postfix) with ESMTP id 862029FB98D for ; Mon, 25 Jun 2007 15:17:29 -0300 (ADT) Received: (qmail 13955 invoked by uid 1010); 25 Jun 2007 18:17:04 +0000 Received: from 88.149.106.19 by mack (envelope-from , uid 1008) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.4/1639. spamassassin: 3.1.4. perlscan: 1.25-st-qms. Clear:RC:1(88.149.106.19):SA:0(-2.4/4.5):. Processed in 2.278472 secs); 25 Jun 2007 18:17:04 -0000 X-Antivirus-HIVE-Mail-From: gnari@hive.is via mack X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(88.149.106.19):SA:0(-2.4/4.5):. Processed in 2.278472 secs Process 13929) Received: from dsl-149-106-19.hive.is (HELO ?192.168.1.33?) (88.149.106.19) by mx1.ipf.is with SMTP; 25 Jun 2007 18:17:02 +0000 Subject: Re: yet another simple SQL question From: Ragnar To: Joshua Cc: pgsql-sql@postgresql.org In-Reply-To: <467FFEF9.5050603@joshuaneil.com> References: <467FFEF9.5050603@joshuaneil.com> Content-Type: text/plain; charset=ISO-8859-1 Date: Mon, 25 Jun 2007 18:33:14 +0000 Message-Id: <1182796394.5953.294.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/203 X-Sequence-Number: 28693 On mán, 2007-06-25 at 12:44 -0500, Joshua wrote: > 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? how about: select regexp_replace(firstname,' .*','') as firstname from footable; or: select substring(firstname FROM '(.*) ') as firstname from footable; gnari