Mysql 左連結問題

lovemelovemycode發表於2012-10-12
目的:查詢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有何錯誤?

相關文章