From: | S S Mani <ssmani(at)stockholding(dot)com> |
---|---|
To: | nuch(at)valigene(dot)com, pgsql-sql(at)hub(dot)org, michael(dot)j(dot)davis(at)tvguide(dot)com |
Subject: | Your Query... |
Date: | 1999-11-29 09:28:20 |
Message-ID: | 38424734.8A549E4D@stockholding.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi
You may have already got a solution. But the most straightforward soln.
would
be :-
SELECT substr(a,1,instr(a,'_')-1)
FROM ....
< From first field to the filed before the first appearance of '_'>
Pl. confirm whether this works.
Bye
S.S.Mani
**************************************************************
RE: [SQL] substring
From: Michael J Davis <michael(dot)j(dot)davis(at)tvguide(dot)com>
To: "'Nuchanard Chiannilkulchai'" <nuch(at)valigene(dot)com>,
pgsql-sql(at)hub(dot)org
Subject: RE: [SQL] substring
Date: Mon, 26 Apr 1999 14:35:16 -0500
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(at)valigene(dot)com]
> Sent: Monday, April 26, 1999 8:57 AM
> To: pgsql-sql(at)hub(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Stoyan Genov | 1999-11-29 09:38:08 | Re: [SQL] recusrion |
Previous Message | S S Mani | 1999-11-29 09:14:51 | Your query ... |