Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f63KCLa59062 for ; Tue, 3 Jul 2001 16:12:21 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5QM1xa88543 for ; Tue, 26 Jun 2001 18:01:59 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f5QLx4t12005 for pgsql-sql@postgresql.org; Tue, 26 Jun 2001 17:59:04 -0400 (EDT) (envelope-from news) From: jim_esti@hotmail.com (Jim) X-Newsgroups: comp.databases.postgresql.sql Subject: Text manipulation in SQL Date: 26 Jun 2001 14:59:00 -0700 Organization: http://groups.google.com/ Lines: 32 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-support@google.com To: pgsql-sql@postgresql.org X-Archive-Number: 200107/23 X-Sequence-Number: 3804 Hi All, I have a column with a variety of names in it, for example John, Smith John, A S Jane, Doe A Jane, A I will call this column NAMES for this. I was looking to manipulate that column. Specifically: The NAME field will be split after the rightmost blank. Letter on the right of that blank will be displayed as LAST_NAME, the remainder will be displayed as FIRST_NAME. Does anyone know how to do this correctly? I have tried something like this: LTRIM( NAME, (substr(NAME,1,(INSTR(NAME,' ',1,1))))) But that would only yield something like this: John, John, Jane, Jane, My little bit of code seems to only extract up to the first blank space. Which would only work correctly if the names where only in two parts (like Jane, A). As I said I would like to return the NAME column in two parts (the letters to the right of the right most blank, and the other half). It seems a little trick to me. Anyone have any advice, hints, or solutions?