Google Answers Logo
View Question
Q: MySQL delete redundant fields ( No Answer,   2 Comments )
Subject: MySQL delete redundant fields
Category: Computers > Programming
Asked by: lightray-ga
List Price: $20.00
Posted: 17 Oct 2006 09:18 PDT
Expires: 24 Oct 2006 12:35 PDT
Question ID: 774362
I want the source code to a Java class that will delete redundant
records in a MySQL table.  The table has five fields and due to an
error in code that populated the table, I now have several redundant
records spread throughout it.  I want to run a simple program that
will delete these rendundant records and leave only one unique record.
there is shareware that does this for about $20, but it doesn't work
well, and I'd like the simple code that does this anyway.
There is no answer at this time.

Subject: Re: MySQL delete redundant fields
From: frankcorrao-ga on 17 Oct 2006 09:49 PDT
Fortunately because mysql doesnt't really have much by way of
referential action that I know of, it is pretty easy to do.  Let's
call the table you are cleaning up A.  Create a table with the same
schema B.  Then run the following sql in this order:
insert into B
select distinct * from A;
Delete from A;
insert into A
select * from B;
drop table B;
Subject: Re: MySQL delete redundant fields
From: lightray-ga on 17 Oct 2006 15:11 PDT
good answer!  it worked

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy