例如这样一个表,我想统计email和passwords都不相同的记录的条数

 CREATE TABLE IF NOT EXISTS `test_users` (
`email_id` int(11) unsigned NOT NULL auto_increment,
`email` char(100) NOT NULL,
`passwords` char(64) NOT NULL,
PRIMARY KEY (`email_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; INSERT INTO `test_users` (`email_id`, `email`, `passwords`) VALUES
(1, ‘[email protected]', ‘1e48c4420b7073bc11916c6c1de226bb'),
(2, ‘[email protected]', ‘5294cef9f1bf1858ce9d7fdb62240546′),
(3, ‘[email protected]', ‘5294cef9f1bf1858ce9d7fdb62240546′),
(4, ‘[email protected]', ”),
(5, ‘[email protected]', ”); 

通常我们的做法是这样

SELECT COUNT(*) FROM test_users WHERE 1 = 1 GROUP BY email,passwords 

这样的结果是什么呢?

COUNT(*)
1
2
1
1

显然这不是我要的结果,这样统计出来的是相同email和passwords的各个记录数量之和,下面这样就可以了

SELECT COUNT(DISTINCT email,passwords) FROM `test_users` WHERE 1 = 1 
05-10 16:02