RokNewsRotator Module

The RokNewsRotator widget is designed to display and rotate your content dynamically. This is achieved through the power of the Mootools javascript library which allows the module to perform elegant transitions between the posts of categories you assigned in its settings. Learn More...
MySQL: Remove Duplicate Entries
MySQL: Remove Duplicate Entries

Remove duplicate entries in your Database is fairly hardcore, and should be dangerous. Two easy possibilities allow to remove duplicate entries

mysql

Before, make a backup of your database. Now, The frist simple way, without modify the structure of your table, is to copy your table in a new one, by selecting only distinct rows :


INSERT INTO newtable SELECT DISTINCT uniqueid FROM duplicatetable GROUP BY uniqueid

Now, in newtable, you have distinct records of duplicatetable. You just have to empty duplicatetable and replace by records from newtable.

You can also simply alter your table, by adding a unique index. The other approach is to simply add a UNIQUE index to the current table and thereby let MySQL do the hardcore identification and deletion job.


ALTER IGNORE TABLE 'duplicatetable' ADD UNIQUE 'nameOfTheIndex' ( 'uniqueid' ( 255 ) )

That’s all, the table is clean

TAGS: