問題:選擇日期範圍內的資料會導致排除上限日期,因為預設午夜
查詢:
SELECT `users`.* FROM `users` WHERE created_at >= '2011-12-01' AND created_at <= '2011-12-06'
解決方案:
解決方案:SELECT users.* FROM users WHERE created_at >= '2011-12-01' AND created_at <= '2011-12-07'
SELECT users.* from users WHERE created_at >= '2011-12-01' AND created_at <= date_add('2011-12-01', INTERVAL 7 DAY)
SELECT users.* from users WHERE created_at BETWEEN('2011-12-01', date_add('2011-12-01', INTERVAL 7 DAY))
以上是在 MySQL 中選擇兩個日期之間的資料時如何包含上限日期?的詳細內容。更多資訊請關注PHP中文網其他相關文章!