pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Tom Rochester <tomr@chu.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: substr_count
Date: Thu, 10 Jul 2003 09:36:50 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.com> (raw)
In-Reply-To: <3F0CEDC8.9000304@chu.com.au>

On Thu, 10 Jul 2003, Tom Rochester wrote:

> Hey all,
> 
> I would like to achive something along the lines of:
> 
> SELECT field FROM table WHERE field ILIKE '$searchterm' ORDER BY 
> substr_count(field, '$searchterm');
> 
> Of course the substr_count function does not exist. Is there anyway to 
> do this?
> 
> I had a thought char_count(replace(field, !$searchterm, '')) might do 
> the job but replace doesn't allow for 'replace everything NOT string';

You'll likely have to code a bit in pl/pgsql.  The regex capable substring 
of 7.3 might come in handy.




view thread (5+ messages)  latest in thread

Message-ID: <Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.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: scott.marlowe@ihs.com, tomr@chu.com.au
  Subject: Re: substr_count
  In-Reply-To: <Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.com>
  References: <3F0CEDC8.9000304@chu.com.au> <Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.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