0
('SELECT id,username,tag,message,timestamp FROM mybq_txt where id = ? AND (MONTH('date') BETWEEN (DATE_SUB(NOW() , INTERVAL 30 DAY) AND NOW()')));
我正試圖選擇上個月內的內容。這個PDO有什麼問題'Month ... Between'Query?
('SELECT id,username,tag,message,timestamp FROM mybq_txt where id = ? AND (MONTH('date') BETWEEN (DATE_SUB(NOW() , INTERVAL 30 DAY) AND NOW()')));
我正試圖選擇上個月內的內容。這個PDO有什麼問題'Month ... Between'Query?
,您應該使用反勾,而不是單引號:
.... AND (MONTH(`date`) BETWEEN ....
^here
但我不認爲你必須使用MONTH
功能,只需使用日期範圍之間的日期。
查詢應該是:
SELECT id,username,tag,message,timestamp
FROM mybq_txt where id = ?
AND `date` BETWEEN DATE_SUB(NOW() , INTERVAL 30 DAY) AND NOW()
涼爽。現在工作。 – adeoba