爲什麼我會爲這個類似的查詢得到不同的結果?如何檢查日期是否在MySQL的範圍內?
SELECT CASE WHEN CONCAT(2011, '-1-1') BETWEEN '2011-01-01' AND '2011-03-31' THEN 1 ELSE 0 END AS status;
+--------+
| status |
+--------+
| 0 |
+--------+
SELECT CASE WHEN CONCAT(2011, '-1-1') BETWEEN '2011-1-1' AND '2011-3-31' THEN 1 ELSE 0 END AS status;
+--------+
| status |
+--------+
| 1 |
+--------+
'CAST(CONCAT(2011,'-1-1')AS DATE)'也應該這樣做。 – 2011-04-05 18:55:44