Re: MySQL Query Puzzle
| From: | Jim Lucas | 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 1Use the SQL command alter with the ignore flag. ALTER IGNORE TABLEa1a2b3c3ci want the above table need to be as below, After executing the mysql query. column1column21a2b3cThanks in advance.. Regards Peter
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