;CREATE TABLEtabtest (' id 'INT( One) not NULLauto_increment, ' Factora 'VARCHAR(255) not NULL DEFAULT ' ', ' Factorb 'VARCHAR(255) not NULL DEFAULT ' ', ' Factorc 'DECIMAL(Ten,2) not NULL DEFAULT 0, ' remark 'VARCHAR(255) not NULL DEFAULT ' ' , PRIMARY KEY(' id ')) ENGINE=INNODB auto_increment=0 DEFAULTCHARSET=UTF8 COMMENT="';INSERT intotabtest (Factora, Factorb, FACTORC, remark)SELECT 'A1','B1',0.5,'1..'UNION All SELECT 'A1','B1',0.5,'2..'UNION All SELECT 'A2','B2',0.5,'3..'UNION All SELECT 'A2','B2',1.5,'4..'UNION All SELECT 'A2','B2',0.5,'5..';SELECT * fromTabtest;
-- programme I ; DELETE from WHERE not inch SELECT * from SELECT from GROUP by Factora, Factorb, FACTORC) b);
--Scenario TwoDELETE fromTabtestWHEREIdinch ( --MySQL Error 1093–can ' t specify target table for update on FROM clause SELECTb.ID from ( SELECTTouter. ' ID ' fromtabtest TouterINNER JOIN ( SELECTtinner.id, Tinner.factora, Tinner.factorb, Tinner.factorc fromtabtest TinnerGROUP byTinner.factora, Tinner.factorb, Tinner.factorc having COUNT(1)> 1) A onTouter. ' Factora '=A. ' Factora ' andTouter. ' Factorb '=A. ' Factorb ' andTouter. ' Factorc '=A. ' Factorc 'WHERETouter. ' ID '<>A. ' id ') b)
Plan One: data volume hours, more convenient
Scenario Two: when the data volume is large, the first scheme is tested under 700,000 data, 5 minutes out of the results, discard, use the second scheme, the second end.
Delete duplicate records (MySQL) under a specific impact factor (field column)