I have this query
SELECT theMonth,
sum( Sales ) AS sumSales,
sum( Saleswotax ) AS sumSaleswotax,
sum( Purchases ) AS sumPurchases,
sum( Purchaseswotax ) AS sumPurchaseswotax
FROM (SELECT date_format( saledate, '%M' ) AS theMonth,
sales.cost AS Sales,
ROUND( sales.cost * 0.85, 2 ) AS Saleswotax,
0 AS Purchases,
0 AS Purchaseswotax
FROM sales, products
WHERE sales.product = products.name
AND category = 'Service'
OR category = 'Accommodation'
UNION ALL
SELECT date_format( purchasedate, '%M' ) AS theMonth,
0 AS Sales,
0 AS Saleswotax,
purchases.cost AS Purchases,
ROUND( purchases.cost * 0.85, 2 ) AS Purchaseswotax
FROM purchases) AS all_costs
GROUP BY theMonth
This is meant to show the total sales and purchases for the current year.
It works fine in that regard, but seems to ignore my category WHERE clause.
If I replace service with xxx and accommodation with jjj I still get the same result.
The category field is only in the products table, but changing category to products.category made no difference.
Why is it not giving an error, why is it simply ignoring the clause?