substring

From: Nuchanard Chiannilkulchai <nuch(at)valigene(dot)com>
To: pgsql-sql(at)hub(dot)org
Subject: substring
Date: 1999-04-26 14:57:05
Message-ID: 37247EC0.AA67A0F5@valigene.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message Justin Long 1999-04-26 15:52:44 CURRVAL(INDEX)
Previous Message José Soares 1999-04-26 12:44:14 Re: [SQL] Primary Key Bugs