如何在mysql下面的结构化表中找到重复的条目

时间:2012-10-22 11:59:15

标签: mysql

如何在以下MySQL表中找到重复的条目?我担心的是这个表的大小是500 MB并且还在增长。

CREATE TABLE `phone_observations` (
`email_address` varchar(256) NOT NULL,
`phone_number` varchar(64) NOT NULL,
`phone_type` varchar(16) NOT NULL DEFAULT 'unknown',
`unix_time` int(10) unsigned NOT NULL,
`guid` int(10) unsigned NOT NULL,
`spammy` tinyint(1) NOT NULL DEFAULT '0',
KEY `phone_observations_phone_number` (`phone_number`),
KEY `phone_numbers_phone_type` (`phone_type`),
KEY `idx_spam` (`spammy`),
KEY `idx_guid_mail_time` (`guid`,`email_address`,`unix_time`)
`unique_phone_observations` (`email_address`,`phone_number`,`unix_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

我不知道从哪里开始。

1 个答案:

答案 0 :(得分:2)

您可以使用以下内容:

SELECT COUNT(*) AS `c`, `email_address`, `phone_number`, ... /* list all your columns here */
FROM `phone_observations`
GROUP BY `email_address`, `phone_number`, ... /* list all your columns here */
HAVING `c`>1