mysql去除重复数据
在crm中,电话号码就往往就代表了一个客户,所以往往电话号码不能出现重复数据,下面就根据客户表client的phone字段去除重复数据:
- 查询重复数据:
select phone,count(phone) as c from client group by phone having c>1;
- 去除重复数据,只保留一个:
delete from client where id not in (select * from (select id from client group by phone) b )