我使用此查詢從昨天獲得所有銷售。將其導出到某處。
由於有很多取消,待付款,處理等,我以爲只導出已完成的。mysql忽略哪裏聲明
但不知何故,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
';
這應該完全正常 - 你確定你的問題不在其他地方嗎?你有沒有嘗試用''''s和相反的方法來切換''''? – h2ooooooo
不,我會試試 –
看不到你有問題的原因,但你似乎有一個無意的交叉連接(沒有JOIN條件指定加入到sakes_order_status) – Kickstart