MySQL 删除重复的记录(简单可行)
在网上找到的很多文章,都挺复杂而且不易理解,我自己写了个,应该很容易理解。
假设表结构为:
CREATE TABLE `orders` (
`id` int(11) NOT NULL auto_increment,
`person_name` varchar(12) default NULL,
`address` varchar(12) default NULL,
`tel` varchar(12) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
删除其中除id外重复的记录:
delete a from orders as a, orders as b where a.person_name=b.person_name and a.address=b.address and a.tel=b.tel and a.id<b.id