Link to home
Start Free TrialLog in
Avatar of bigelz1215
bigelz1215

asked on

removal of duplicate records in a table in an informix 6 database

i am using an informix 6 database.
I have a tabl;e which unfortunately has been updated twice with the same records.
How can I remove the duplicate set of record uing sql, the records are identical - I thought that perhaps use of the rowid may be the answer - can you help
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image


Hi bigelz1215,

This is a DB2 forum, so be wary of answers to non-DB2 questions.  :)

The solution below won't work on DB2, but it will work on other flavors of SQL.  Your mileage may vary....

delete table_a
where rowid not in
     (select min(rowid) from table_a
       group by column1, column2);


You can also chase a cursor through the data, selecting the duplicates via the cursor and deleting them by the cursor.


Good Luck!
Kent
ASKER CERTIFIED SOLUTION
Avatar of ghp7000
ghp7000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

And I hate chasing cursors.   :(
Avatar of bigelz1215
bigelz1215

ASKER

Thanks for the help - I have used your idea with rowids and have come up with a solution which has worked
many thanx
dave