此查询:payment_date BETWEEN "old date" AND "new date"
只有在我们在新日期之前写入旧日期时才会成功运行。如果查询如何使其工作payment_date BETWEEN "new date" AND "old date"
?因为有时用户先输入新日期,然后才输入旧日期。示例代码:
$sql = "SELECT customer_name, phone_number, address FROM sale
WHERE seller_id=? && $search_by LIKE ? && payment_date BETWEEN ? AND ?";
$q = $conn->prepare($sql);
$result = $q->execute(array($userid, "%".$search_value."%", $oldPaymentDate, $newPaymentDate));