From: Rod Taylor <rbt@rbt.ca>
To: Tom Rochester <tomr@chu.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: substr_count
Date: 10 Jul 2003 13:43:06 +0000
Message-ID: <1057844586.46100.129.camel@jester> (raw)
In-Reply-To: <3F0CEDC8.9000304@chu.com.au>
References: <3F0CEDC8.9000304@chu.com.au>
On Thu, 2003-07-10 at 04:38, 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';
How about:
(char_count(field) - char_count(replace(field, $searchterm, '')))
Attachments:
signature.asc (application/pgp-signature, 186B) download
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rbt@rbt.ca, tomr@chu.com.au
Subject: Re: substr_count
In-Reply-To: <1057844586.46100.129.camel@jester>
* 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