Re: delete duplicates, how?

From: Michael Krall <mkrall_at_ma.ultranet.com>
Date: Fri, 12 Feb 1999 21:09:31 -0500
Message-ID: <7a2mtp$hq2$1_at_ligarius.ultra.net>


Adam,

By deleting by rowid > min(rowid) it will delete all rows from the group by (a.field = b.field) but the one row where rowid = min(rowid).

Michael

Adam Tadjkarimi wrote in message <7a1h8f$dtp$1_at_newsin-1.starnet.net>...
>Michael,
>
>I think if the number of rows with identical values in the column(s) meant
>for indexing was more than
>two, your script will fall short.
>
>Thanks,
>Adam Tadj
>Adamt_at_hsltd.com
>
>Opinions expressed or questions asked are mine not of my employer.
>
>Michael Krall wrote in message <79vv71$vaf$1_at_ligarius.ultra.net>...
>>
>>Rune Lysbakken wrote in message <36c28c6b.388959_at_news.online.no>...
>>>I want to create an unique index but I have some duplicate values. I
>>>think I can find them with a combination of count, group and having
>>>Count ()> 1 but how can I delete so that only one of the duplicates
>>>remains? Use rowid perhaps?
>>>
>>>regds Rune
>>Rune,
>>Try something along the lines of :
>>
>>delete from <tablename> a
>> where rowid > (select min(rowid)
>> from <tablename> b
>> where a.<fieldname>=b.<fieldname>);
>>
>>Hope this helps.
>>Michael Krall
>>Senior Systems Engineer
>>Safety 1st
>>
>>
>>
>
>
Received on Sat Feb 13 1999 - 03:09:31 CET

Original text of this message