如何显示记录取决于最近的日期和自定义时间
问题描述:
我想只显示自最近14天以来没有订购的客户的记录。 所以我需要从当前日期中扣除最后一个订单日期,并仅显示自14天或更长时间以来没有订购的人员。 注意,日期格式分类数据库是这样的:2017年1月25日和数据类型varchr(不能更改) 这里我的代码如何显示记录取决于最近的日期和自定义时间
<?php
$q_customer = $conn->query("SELECT * FROM customer_order INNER JOIN customer on customer_order.phone= customer.phone GROUP BY customer_order.phone") or die(mysqli_error());
while($f_customer = $q_customer->fetch_array()){
?>
<tr>
<td><?php echo $f_customer['phone']?></td>
<td><?php echo $f_customer['first_name']?></td>
<td><?php echo $f_customer['last_name']?></td>
<td><?php echo $f_customer['order_date']?></td>
</tr>
<?php
}
?>
答
在代码中添加一个group by customer_id
,然后添加一个where条件按日期过滤订单。