我使用此查询来获取昨天的所有销售额。将其导出到某个地方。
由于有很多已取消,待付款,处理等,我想只导出已完成的。
但不知何故,mysql只是忽略了拳头限制。我一直得到所有的销售。我写什么并不重要。它只需要是昨天使用的状态。
$sql = '
SELECT
sales_flat_order_grid.entity_id,
sales_flat_order_grid.increment_id AS increment_id,
sales_flat_order_grid.quote_id AS quote_id,
sales_flat_order_grid.store_name AS store_name,
sales_flat_order_grid.created_at AS created_at,
sales_flat_order_grid.billing_name AS billing_name,
sales_flat_order_grid.payment_method AS payment_method,
sales_flat_order_grid.grand_total AS grand_total,
sales_order_status.label AS status,
sales_flat_order_item.sku AS sku,
sales_flat_order_item.name AS name,
sales_flat_order_item.price_incl_tax AS price_incl_tax,
sales_flat_order_item.product_options AS product_options,
sales_flat_order_payment.additional_information AS additional_information
FROM
sales_flat_order_grid,
sales_order_status,
sales_flat_order_item,
sales_flat_order_payment
WHERE
sales_flat_order_grid.status = "Complete"
AND sales_flat_order_grid.entity_id = sales_flat_order_item.order_id
AND sales_flat_order_grid.entity_id = sales_flat_order_payment.entity_id
AND sales_flat_order_grid.created_at >= "' . $date . ' 00:00:00"
AND sales_flat_order_grid.created_at <= "' . $date . ' 23:59:59"
ORDER BY
sales_flat_order_grid.entity_id DESC
';