作者:广东狮子会_刘少杰 | 来源:互联网 | 2017-05-12 15:07
下面的例子中可以根据一个或者多个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);
,