X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id BEB60CBF13 for ; Thu, 10 Jul 2003 04:38:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 41715-03 for ; Thu, 10 Jul 2003 01:37:41 -0300 (ADT) Received: from mail.chu.com.au (unknown [203.102.142.58]) by svr1.postgresql.org (Postfix) with SMTP id 02220CBF0D for ; Thu, 10 Jul 2003 01:37:40 -0300 (ADT) Received: (qmail 79977 invoked from network); 10 Jul 2003 04:37:31 -0000 Received: from nsw.chu.com.au (192.168.0.100) by mail.chu.com.au with SMTP; 10 Jul 2003 04:37:31 -0000 Received: (qmail 13440 invoked from network); 10 Jul 2003 04:54:16 -0000 Received: from unknown (HELO chu.com.au) (192.168.0.115) by 192.168.0.100 with SMTP; 10 Jul 2003 04:54:16 -0000 Message-ID: <3F0CEDC8.9000304@chu.com.au> Date: Thu, 10 Jul 2003 14:38:32 +1000 From: Tom Rochester User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021216 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: substr_count Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/122 X-Sequence-Number: 14236 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'; Any Ideas? Thanks in advance, -- Tom Rochester Systems Developer/Administrator CHU Underwriting Agencies Pty Ltd Level 5, 1 Northcliff Street, Milsons Point NSW 2060

02 8923 5346 02 8923 5363 +61416152792 tomr@chu.com.au http://www.chu.com.au/ "The information contained in this email and any attached files is strictly private and confidential. The intended addressee should read this email only. If the recipient of this message is not the intended addressee, please call CHU Underwriting Agencies Pty Ltd on +61 1300 361 263 and promptly delete this email and any attachments. The intended recipient of this email may only use, reproduce, disclose or distribute the information contained in this email and any attached files with CHU's permission. If you are not the intended addressee, you are strictly prohibited from using, reproducing, disclosing or distributing the information contained in this email and any attached files. CHU advises that this email and any attached files should be scanned to detect viruses. CHU accepts no liability for loss or damage (whether caused by negligence or not) resulting from the use of any attached files."