Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id E454E2E00A0 for ; Wed, 16 Apr 2008 03:10:49 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 63579-04-4 for ; Wed, 16 Apr 2008 03:10:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mailserver.ttmail.com (unknown [88.255.235.9]) by developer.postgresql.org (Postfix) with ESMTP id 32E882E0035 for ; Wed, 16 Apr 2008 03:10:33 -0300 (ADT) Received: from SMTP1 ([192.168.19.136]) by mailserver.ttmail.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 16 Apr 2008 09:10:20 +0300 Received: from alamut.mobiliz.com.tr ([213.139.194.86]) by SMTP1 with Microsoft SMTPSVC(6.0.3790.1830); Wed, 16 Apr 2008 09:10:19 +0300 Received: from (unknown [213.139.194.86]) by AVGW-TTMAIL-1.ttmail.com with smtp id 3155_c8bc9c5a_0b7b_11dd_a62a_00142217b48c; Wed, 16 Apr 2008 09:10:18 +0300 From: Volkan YAZICI To: Andreas Cc: pgsql-sql@postgresql.org Subject: Re: How to find double entries References: <48056F5F.30507@gmx.net> Date: Wed, 16 Apr 2008 09:15:42 +0300 In-Reply-To: <48056F5F.30507@gmx.net> (Andreas's message of "Wed, 16 Apr 2008 05:15:43 +0200") Message-ID: <87zlru72b5.fsf@alamut.mobiliz.com.tr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Report: 0 Rules triggered X-OriginalArrivalTime: 16 Apr 2008 06:10:19.0814 (UTC) FILETIME=[8C4ACC60:01C89F88] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/90 X-Sequence-Number: 30629 On Wed, 16 Apr 2008, Andreas writes: > how can I find double entries in varchar columns where the content is > not 100% identical because of a spelling error or the person > considered it "looked nicer" that way? > > I'd like to identify and then merge records of e.g. 'google', > gogle', 'guugle' > > Then I want to match abbrevations like 'A-Company Ltd.', 'a company > ltd.', 'A-Company Limited' > > Is there a way to do this? > It would be OK just to list candidats up to be manually checked > afterwards. You can try something similar to below example. (levenshtein(text, text) function is supplied by fuzzystrmatch module.) SELECT T1.col, T2.col FROM tbl AS T1, INNER JOIN tbl AS T2 ON T1.col <> T2.col AND levenshtein(T1.col, T2.col) < (length(T1.col) * 0.5) Regards.