Received: from carabosse.oleane.net (carabosse.oleane.net [194.2.28.5]) by hub.org (8.9.3/8.9.1) with ESMTP id FAA49555 for ; Tue, 27 Apr 1999 05:08:29 -0400 (EDT) (envelope-from nuch@valigene.com) Received: from tom.oleane.net (root@smtp.dial.oleane.com [194.2.0.54]) by carabosse.oleane.net with ESMTP id LAA08373 for ; Tue, 27 Apr 1999 11:08:26 +0200 Received: from valigene.com ([62.161.254.162]) by tom.oleane.net (8.8.8/8.8.8) with ESMTP id LAA04422 for ; Tue, 27 Apr 1999 11:08:25 +0200 Sender: nuch@tom.oleane.net Message-ID: <37257226.17A344FA@valigene.com> Date: Tue, 27 Apr 1999 10:15:35 +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: Re: [SQL] substring References: <93C04F1F5173D211A27900105AA8FCFC14541D@lambic.prevuenet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit The problem is : select position ('_' in a ) from table_a does not work. ERROR: No such function 'strpos' with the specified attributes while select position('_' in '98-004_c136') ; give the right answer. I wonder how to introduce the attribute , and not the constant value. Michael J Davis wrote: > 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) ? > > [snips] > > 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 > >