Received: from morgane.oleane.net (Morgane.OLEANE.Net [194.2.1.9]) by hub.org (8.9.3/8.9.1) with ESMTP id LAA34163 for ; Mon, 26 Apr 1999 11:50:05 -0400 (EDT) (envelope-from nuch@valigene.com) Received: from tom.oleane.net (root@tom.oleane.net [194.2.28.14]) by morgane.oleane.net with ESMTP id RAA20724 for ; Mon, 26 Apr 1999 17:50:04 +0200 Received: from valigene.com ([62.161.254.162]) by tom.oleane.net (8.8.8/8.8.8) with ESMTP id RAA18184 for ; Mon, 26 Apr 1999 17:50:02 +0200 Sender: nuch@tom.oleane.net Message-ID: <37247EC0.AA67A0F5@valigene.com> Date: Mon, 26 Apr 1999 16:57:05 +0200 From: Nuchanard Chiannilkulchai Organization: ValiGene X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i686) MIME-Version: 1.0 To: pgsql-sql@hub.org Subject: substring Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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