在MySQL单个表中找到重复的值

1、一个表中单个列重复的值

SELECT
    id,
    firstName,
    lastName,
    email,
    COUNT(*)
FROM
    contacts
GROUP BY
    firstName
HAVING
    COUNT(firstName) > 1;

结果是:其中count(*)是表示重复的次数。

在MySQL单个表中找到重复的值

 2、在多个列中查找重复值

SELECT
    id,
    firstName,
    lastName,
    email,
    COUNT(*)
FROM
    contacts
GROUP BY
    firstName,
    lastName,
    email
HAVING
    COUNT(firstName) > 1
AND COUNT(lastName) > 1
AND COUNT(email) > 1;

结果:

在MySQL单个表中找到重复的值

__________________________________________________________________________________

在MySQL单个表中找到重复的值

上一篇:安装ibm_db


下一篇:oracle spool 导出csv |查询出某张表所有字段名,用 ||','|| 分隔