Mysql condition not working

184 views Asked by At

this is my query for getting order total for particular date. Here I can't get proper result when using AND (tos.status!='5' or tos.status!='6'). what is the problem in this?

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')
1

There are 1 answers

0
Saharsh Shah On

Try this:

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)