X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id CF826CDA7D for ; Fri, 11 Jul 2003 23:11:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 63047-01 for ; Fri, 11 Jul 2003 23:11:13 +0000 (GMT) Received: from rtlocal.trade-india.com (unknown [203.196.129.235]) by svr1.postgresql.org (Postfix) with SMTP id 1EDDEDD955 for ; Fri, 11 Jul 2003 06:53:10 -0300 (ADT) Received: (qmail 9547 invoked from network); 11 Jul 2003 10:00:58 -0000 Received: from unknown (HELO system67.trade-india-local.com) (unknown) by unknown with SMTP; 11 Jul 2003 10:00:58 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: Tom Rochester , pgsql-sql@postgresql.org Subject: Re: substr_count Date: Fri, 11 Jul 2003 15:23:16 +0530 User-Agent: KMail/1.5.1 References: <3F0CEDC8.9000304@chu.com.au> In-Reply-To: <3F0CEDC8.9000304@chu.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200307111523.16115.mallah@trade-india.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/144 X-Sequence-Number: 14258 On Thursday 10 Jul 2003 10:08 am, 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'); > Hi In case you are attempting to search text in a feild and sort it by relevence then contrib/tsearch V2 is for you. http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/ regds mallah. > 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'; > > Any Ideas? > > Thanks in advance, -- Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace.