我有一個查詢需要返回ShipDate在日期範圍之間的記錄。下面的查詢工作:日期之間的SQL語法
$query = "SELECT ECCustomerOrder.ShipDate,
ECCustomers.Customer,
ECCustomerOrder.PO,
ECCustomerOrder.TotalCases,
ECCustomerOrder.order_number
FROM ECCustomerOrder INNER JOIN ECCustomers ON ECCustomerOrder.ID = ECCustomers.ID
WHERE ECCustomerOrder.ShipDate >= $todayMinus";
$ todayMinus是一個PHP變量早些時候在接受當前日期減去15天腳本設置。我不能去工作如下:
$query = "SELECT ECCustomerOrder.ShipDate,
ECCustomers.Customer,
ECCustomerOrder.PO,
ECCustomerOrder.TotalCases,
ECCustomerOrder.order_number
FROM ECCustomerOrder INNER JOIN ECCustomers ON ECCustomerOrder.ID = ECCustomers.ID
WHERE ECCustomerOrder.ShipDate BETWEEN $todayMinus AND $todayPlus";
,這是什麼SQL查詢的正確語法爲$ todayMinus和$ todayPlus的ShipDates之間返回記錄?
這是MySQL的?你需要包括今天的結果?爲什麼它不起作用? – Lamak 2013-02-19 19:13:08