mysql 统计重复记录数量

SELECT COUNT(*) as total  FROM (
    SELECT count(openid) as t
    FROM user
    GROUP BY `openid`
    HAVING t > 1 limit 1000
) as a

如果下面写法会很慢

SELECT COUNT(*) as total FROM form_user WHERE id IN(
    SELECT count(id)
    FROM form_user
    GROUP BY `openid`
    HAVING COUNT(openid) > 1 limit 1000
)

相关文章

此处评论已关闭