0%

MySQL筛选多列重复的记录

单列去重比较简单,如果多列要去重,怎么找出重复的值?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
SELECT 
field1, COUNT(field1),
field2, COUNT(field2),
...

FROM
table_name
GROUP BY
field1,
field2,
...
HAVING
(COUNT(field1) > 1) AND
(COUNT(field2) > 1) AND
...