Mysql 左链接问题

12-10-12 lovemelovemycode
目的:查询2012-10-07来访问2012-10-06没有来访问的用户
查询SQL:
SELECT
COUNT(DISTINCT u7.usr_idntf)
FROM
users_wap u7
LEFT JOIN users_wap u6 ON u7.usr_idntf = u6.usr_idntf
WHERE u7.access_date = '2012-10-07'
AND u6.access_date = '2012-10-06'
AND u6.usr_idntf IS NULL

users_wap建表SQL:
CREATE TABLE `users_wap` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`access_date` varchar(12) NOT NULL DEFAULT '1970-01-01' COMMENT '访问时间',
`usr_idntf` varchar(30) NOT NULL DEFAULT '-1' COMMENT '用户标识',
`pv` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '每个用户访问次数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


问题:查询SQL有何错误?

1
猜你喜欢