0
Thanks

A few words of thanks would be greatly appreciated.

MySQL - Delete duplicates in a table






To remove duplicates in a table set up as follows:

CREATE TABLE IF NOT EXISTS TabTest (   
           prim_key integer(4) NOT NULL auto_increment,
           x integer,
           y integer,
           z integer,
           Constraint pk_Tab_test PRIMARY KEY  (rpim_key)    
); 


We should begin by setting the fields related to duplicate (in our case the fields x and y):



To remove duplicate fields in x and y run the command:
ALTER IGNORE TABLE  TabTest ADD UNIQUE INDEX(x,y);
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « MySQL - Delete duplicates in a table », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments