这是我的查询,用于获取特定日期的总订单。在这里,使用AND(tos.status!='5'或tos.status!='6')时无法获得正确的结果。这有什么问题?

SELECT sum(tot.total) as total
FROM orders_totals tot, orders tos
WHERE DATE(tos.`timestamp`) BETWEEN '2013-12-09' AND '2013-12-09' and
      tot.`order` = tos.id and tot.description='Grand-Total' AND
     (tos.status!='5' or tos.status!='6')

最佳答案

尝试这个:

SELECT sum(tot.total) as total
FROM orders_totals tot
INNER JOIN orders tos ON tot.`order` = tos.id
WHERE DATE(tos.`timestamp`) BETWEEN '2013-12-09' AND '2013-12-09' and
      tot.description='Grand-Total' AND tos.status NOT IN (5, 6)

10-07 17:55