Method and code for deleting duplicate records in MYSQL
In practical applications, there may be some repeated records that need to delete some fields. I will write down what I can think of now, and hope the experts can add it.
1,
The specific implementation is as follows:
Table Create Table
--------------------------------------------------------------------
Users_groups create table 'users _ groups '(
'Id' int (10) unsigned not null AUTO_INCREMENT,
'Uid' int (11) not null,
'Gid' int (11) not null,
Primary key ('id ')
) ENGINE = InnoDB AUTO_INCREMENT = 15 default charset = utf8
Users_groups.txt content:
502
2,107,502
3,100,503
4,110,501
5,112,501
6,104,502
7,100,502
8,100,501
9,102,501
10,104,502
11,100,502
12,100,501
13,102,501
14,110,501
Mysql> load data infile 'C:/users_groups.txt 'into table users_groups fields
Rminated by ', 'lines terminated '';
Query OK, 14 rows affected (0.05 sec)
Records: 14 Deleted: 0 Skipped: 0 Warnings: 0
Mysql> select * from users_groups;
Query result (14 records)
Id uid gid
1 11 502
2 107 502
3 100 503
4 110 501
5 112 501
6 104 502
7 100 502
8 100 501
9 102 501
10 104 502
11 100 502
12 100 501
13 102 501
14 110 501
BitsCN.com