Home > Database > Mysql Tutorial > MYSQL的中删除重复记录的方法和代码_MySQL

MYSQL的中删除重复记录的方法和代码_MySQL

WBOY
Release: 2016-06-01 13:50:20
Original
936 people have browsed it

bitsCN.com

   在实际应用中,很可能会碰到一些需要删除某些字段的重复记录,我现在把我能想到的写下来,望高手们补充。

1、
具体实现如下:
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内容:
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
mysql> load data infile 'c:/users_groups.txt' into table users_groups fields
rminated by ',' lines terminated by '';
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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template