你能帮我把这个问题搞定吗
SELECT *
FROM `SC_orders`
LEFT JOIN `SC_customer_reg_fields_values` using(customerID)
WHERE (`statusID` = 2 OR `statusID` = 3 OR `statusID` = 21 OR `statusID` = 25 OR `statusID` = 26) AND DATE(order_time) > '2012-12-01 00-00-00'
LEFT JOIN `SC_ordered_carts`
ON orderID = orderID
GROUP BY orderID
我尝试在一个输出中组合来自3个表的信息。此查询工作正常,没有上一次LEFT JOIN和分组。我的错误在哪里?
答案 0 :(得分:3)
where
需要在最后一次加入之后。另外,第二个ON
子句是不明确的,我认为group by
是不必要的,因为你没有任何聚合函数:
SELECT *
FROM `SC_orders`
LEFT JOIN `SC_customer_reg_fields_values` using(customerID)
LEFT JOIN `SC_ordered_carts` using(orderID)
WHERE (`statusID` = 2 OR `statusID` = 3 OR `statusID` = 21 OR `statusID` = 25 OR `statusID` = 26) AND DATE(order_time) > '2012-12-01 00-00-00'