So I have to make a query to return all the reciept numbers that don't contain an "apple" item.
The data is as follows. EG If you go to the shops and buy apples and bananas the data will be:
(table reciepts)
recieptNumber productCode
12345 9999
12345 8888
(table products)
productCode productName
9999 Apples
8888 Bananas
I was thinking of:
SELECT reciepts.recieptNumber
FROM reciepts JOIN products
ON reciepts.productCode == products.productCode
WHERE products.productName == "Apples"
GROUP BY reciepts.recieptNumber
HAVING COUNT(*) == 0;
But I now know that having doesn't work with count = 0 because there's nothing to count.
Any suggestions?