From: | Michael Pohl <pgsql(at)newtopia(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | Tom Rochester <tomr(at)chu(dot)com(dot)au> |
Subject: | Re: substr_count |
Date: | 2003-07-10 12:55:59 |
Message-ID: | Pine.LNX.4.44.0307100843370.13741-100000@server1.techplant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance pgsql-sql |
On Thu, 10 Jul 2003, Tom Rochester wrote:
> I would like to achive something along the lines of:
>
> SELECT field FROM table WHERE field ILIKE '$searchterm' ORDER BY
> substr_count(field, '$searchterm');
If you have plperl installed:
create or replace function substr_count(
varchar(255),
varchar(255)
)
returns int as '
my ($field, $searchterm) = @_;
my $count = $field =~ s/$searchterm//g;
return $count;
' language 'plperl';
michael
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Bowlby | 2003-07-10 15:09:10 | Re: Some very weird behaviour.... |
Previous Message | Oliver Scheit | 2003-07-10 08:29:46 | Re: Can you help me? |
From | Date | Subject | |
---|---|---|---|
Next Message | Rod Taylor | 2003-07-10 13:32:00 | Re: Recursive request ... |
Previous Message | Yasir Malik | 2003-07-10 12:25:13 | Re: help yourself by helping others |