【发布时间】:2020-04-02 10:36:37
【问题描述】:
我有两张桌子
laces_users_profilelaces_order
laces_order 有所有用户的订单列表。
laces_users_profile 拥有所有客户数据。
laces_users_profile 具有唯一键 laces_user_id,即 laces_order 中的外键。
我的表格是这样的
laces_orders
laces_users_profile
我要检索过去 30 天内没有订购的所有客户。
【问题讨论】:
-
这里的大多数人都希望样本表数据和预期结果为格式化文本,而不是图像。 (而且我无法阅读那个微小的图像文本......)
-
您应该考虑在整个数据库中使用更一致的命名约定。例如,如果表名为
laces_users_profile,则订单应该有laces_user_profile_id或其他名称,而不是customer_id。或者您应该调用laces_users_profile表customers。 -
如果我今天添加客户怎么办?我也将被视为客户在过去 30 天内未下订单。它不应该发生。最近添加的客户不应出现在最近 30 天内未下订单的客户列表中。如何达到那个条件。 @BadHorsie