sql删除重复数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
select * from crm_customer
WHERE id in (
select id from chongfu
)
AND id NOT IN (
select id from chongfumin
) order by phone_no
;
update crm_customer set del_flag=1
WHERE id in (
select id from chongfu
)
AND id NOT IN (
select id from chongfumin
) order by phone_no
;
insert into chongfumin
select * from crm_customer where id in (
SELECT
min(id)
FROM
crm_customer
GROUP BY
phone_no
HAVING
count(phone_no) > 1
);
insert into chongfu
select * from crm_customer where phone_No in
SELECT
phone_no
FROM
chongfu
GROUP BY
phone_no
HAVING
count(phone_no) > 1