Home >Database >Mysql Tutorial >查询某表中存在重复的记录

查询某表中存在重复的记录

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:01:101060browse

下面的例子中可以根据一个或者多个fieldfield来判断是否为重复记录。假设某表employees有如下三列:pk, id, email

下面的例子中可以根据一个或者多个fieldfield来判断是否为重复记录。

假设某表employees有如下三列:

pk, id, email

根据id字段来判断重复

select * from employees where id in (select id from employees group by id having count(id) > 1);

根据id和email字段来判断重复

select * from employees e where (e.id, e.email) in (select id, email from employees group by id, email having count(*) > 1);

linux

Statement:
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