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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:01:10
Original
1052 people have browsed it

下面的例子中可以根据一个或者多个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

Related labels:
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