pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: S S Mani <ssmani@stockholding.com>
To: nuch@valigene.com
To: pgsql-sql@hub.org
To: michael.j.davis@tvguide.com
Subject: Your Query...
Date: Mon, 29 Nov 1999 14:58:20 +0530
Message-ID: <38424734.8A549E4D@stockholding.com> (raw)

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.j.davis@tvguide.com>
     To: "'Nuchanard Chiannilkulchai'" <nuch@valigene.com>,
pgsql-sql@hub.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@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
>






view thread (2+ messages)

Message-ID: <38424734.8A549E4D@stockholding.com>
Permalink:  ../38424734.8A549E4D@stockholding.com/
Also on:    postgresql.org/message-id/38424734.8A549E4D@stockholding.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ssmani@stockholding.com, nuch@valigene.com, pgsql-sql@hub.org, michael.j.davis@tvguide.com
  Subject: Re: Your Query...
  In-Reply-To: <38424734.8A549E4D@stockholding.com>
  References: <38424734.8A549E4D@stockholding.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox