pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mezei Zoltán <mezei.zoltan@telefor.hu>
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Duplicate records
Date: Fri, 02 Feb 2007 14:54:24 +0100
Message-ID: <45C34290.2090300@telefor.hu> (raw)
In-Reply-To: <55c095e90702020548h4c5ae5b2h405a2a33fb5b950@mail.gmail.com>
References: <55c095e90702020548h4c5ae5b2h405a2a33fb5b950@mail.gmail.com>

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



view thread (9+ messages)  latest in thread

Message-ID: <45C34290.2090300@telefor.hu>
Permalink:  ../45C34290.2090300@telefor.hu/
Also on:    postgresql.org/message-id/45C34290.2090300@telefor.hu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mezei.zoltan@telefor.hu, ezequias.rocha@gmail.com
  Subject: Re: Duplicate records
  In-Reply-To: <45C34290.2090300@telefor.hu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox