Received: from corppo1.uvsg.com (corppo1.uvsg.com [192.40.65.90]) by hub.org (8.9.3/8.9.1) with ESMTP id PAA68302 for ; Mon, 26 Apr 1999 15:39:39 -0400 (EDT) (envelope-from michael.j.davis@tvguide.com) Received: from prevuepo1.prevuenet.com (prevuepo1.uvsg.com [192.40.65.44]) by corppo1.uvsg.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0) id JCBQ76N6; Mon, 26 Apr 1999 14:39:08 -0500 Received: by prevuepo1.uvsg.com with Internet Mail Service (5.5.2232.9) id ; Mon, 26 Apr 1999 14:42:07 -0500 Message-ID: <93C04F1F5173D211A27900105AA8FCFC14541D@lambic.prevuenet.com> From: Michael J Davis To: "'Nuchanard Chiannilkulchai'" , pgsql-sql@hub.org Subject: RE: [SQL] substring Date: Mon, 26 Apr 1999 14:35:16 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2232.9) Content-Type: text/plain try: select a, substring(a, 1, position('_' in a) -1) from table_a; I have not tested this. Not sure if the parameters to substring are correct. Also not sure if the -1 is needed. > -----Original Message----- > From: Nuchanard Chiannilkulchai [SMTP:nuch@valigene.com] > Sent: Monday, April 26, 1999 8:57 AM > To: pgsql-sql@hub.org > Subject: [SQL] substring > > Hello, > > How should I do my query to put a substring value in a field, in > postgres ( I have 6.4) ? > > I have in table table_a > a > ---------------- > 98-004_c136 > P124_154 > 98-005_c171 > > and i want to select only the text before the underscore: > > in sybase, this should be > select a, substring(a,1,charindex('_',a)-1) from table_a > a > ---------------- ---------------- > 98-004_c136 98-004 > 98-005_c171 98-005 > P124_154 P124 > > Thanks a lot, > Nuch > > >