Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 3A3A59FB283 for ; Fri, 2 Feb 2007 10:29:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 26389-08 for ; Fri, 2 Feb 2007 10:29:27 -0400 (AST) X-Greylist: delayed 00:29:45.348397 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 7CA9F9FB1DD for ; Fri, 2 Feb 2007 10:29:32 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail.telefor.hu (mail.telefor.hu [193.68.53.97]) by svr4.postgresql.org (Postfix) with ESMTP id 31EC35AF89A for ; Fri, 2 Feb 2007 13:59:45 +0000 (GMT) Received: from telefor-server.int.telefor-new.hu (telefor-server.int.telefor-new.hu [10.0.20.100]) by mail.telefor.hu (Postfix) with ESMTP id D24A11C078; Fri, 2 Feb 2007 14:59:34 +0100 (CET) Received: from [10.0.20.33] ([10.0.20.33]) by telefor-server.int.telefor-new.hu with Microsoft SMTPSVC(6.0.3790.1830); Fri, 2 Feb 2007 14:54:40 +0100 Message-ID: <45C34290.2090300@telefor.hu> Date: Fri, 02 Feb 2007 14:54:24 +0100 From: =?ISO-8859-1?Q?Mezei_Zolt=E1n?= Organization: Telefor kft. User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 To: Ezequias Rodrigues da Rocha Cc: pgsql-sql@postgresql.org Subject: Re: Duplicate records References: <55c095e90702020548h4c5ae5b2h405a2a33fb5b950@mail.gmail.com> In-Reply-To: <55c095e90702020548h4c5ae5b2h405a2a33fb5b950@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Feb 2007 13:54:40.0404 (UTC) FILETIME=[AF273540:01C746D1] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200702/17 X-Sequence-Number: 27351 Ezequias Rodrigues da Rocha wrote: > Hi list, > > I am making some data minning and would like to know if someone tell > me how to retrieve the duplicate records based in one or two fields of > my table. > > Any help would be welcomed. You can use a simple query like this one: select t1.id, t2.id from table t1, table t2 where t1.record1 = t2.record1 and t1.record2 = t2.record2 and t1.id != t2.id This one lists the ids of the matching records. You may need to fine tune it to your needs, e.g. use distinct or replace the != with <. Zizi