我只是一个MySQL初学者。这是第一次让我们在STACKOVERFLOW上询问有关使用HAVING和WHERE的查询:
SELECT
BOXNUMBER
,COUNT(BOXNUMBER) AS QTY
,CDATETIME
FROM
HSS_SNO
WHERE
year(CDATETIME) IN ('2008','2010','2014')
GROUP BY
BOXNUMBER ;
/* Affected rows: 0 Found rows: 13,928 Warnings: 0 Duration for 1 query: 0.031 sec. (+ 2.782 sec. network) */
SELECT
BOXNUMBER
,COUNT(BOXNUMBER) AS QTY
,CDATETIME
FROM
HSS_SNO
GROUP BY
BOXNUMBER
HAVING
year(CDATETIME) IN ('2008','2010','2014');
/* Affected rows: 0 Found rows: 13,922 Warnings: 0 Duration for 1 query: 0.047 sec. (+ 2.594 sec. network) */
我认为这些查询会给我相同的结果,但“找到的行”彼此不同。 你能告诉我为什么这样吗?
由于 托宾 (抱歉我的英文)