Re: MySQL Query Puzzle

From: Date: Tue, 20 Jul 2010 04:37:15 +0000
Subject: Re: MySQL Query Puzzle
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-307024@lists.php.net to get a copy of this message
Peter wrote:
Hi All, I have a table which contain's some duplicate rows. I just want to delete the duplicate records alone not original records. Assume my table as look as below column1 column2 1
    a
1
    a
2
    b
3
    c
3
    c
i want the above table need to be as below, After executing the mysql query. column1
    column2
1
    a
2
    b
3
    c
Thanks in advance.. Regards Peter
Use the SQL command alter with the ignore flag. ALTER IGNORE TABLE your_table ADD UNIQUE ( column1 , column2 ) I tested this on my test DB and it worked fine. It erased all the duplicates and left one instance of the multiple entry values. This will add a permanent unique restraint to the table. So, you will never have dupps again. Jim Lucas

« previous php.general (#307024) next »