Method and code for deleting duplicate records in MYSQL _ MySQL

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.