Skip site navigation (1) Skip section navigation (2)

Re: Removing duplicate entries

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Scott Ford <Scott(dot)Ford(at)bullfrogpower(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Removing duplicate entries
Date: 2006-01-11 20:05:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On 1/11/06, Scott Ford <Scott(dot)Ford(at)bullfrogpower(dot)com> wrote:
> Hi all -
> I have two tables - customers and documents.  Each customer can be
> related to several different documents.  There has been a bug in some
> software that's been duplicating the addition of a certain type of
> document for the customers.  Even though each customer can have
> documents of the same type, in this case I don't want it.
> customers
>        customer_id
>        ...
> documents
>        customer_id
>        document_id
>        document_type_id
>        ...
> So, for example, there are two documents with the same document_type_id
> associated with one customer.
> Can someone help me with a SQL statement that might help me remove the
> duplicate documents for a certain document_type_id?
> Thanks,
> Scott.

i think what you need is a SQL to _search_ all the cases...
then look at them... and deletes them one at a time... that's the
safer way to go...

Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

pgsql-novice by date

Next:From: Michael FuhrDate: 2006-01-11 20:18:04
Subject: Re: Removing duplicate entries
Previous:From: Scott FordDate: 2006-01-11 19:06:53
Subject: Removing duplicate entries

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group