I'm having a problem whereby one of the joins I am making seems to be ignored but I have very little experience with joins and so I'm either doing it wrong or it isn't possible.
Let me explain.
I have the four following tables which relate to products and orders for the products. I have only included the relevant fields.
Name: Products (Product Information)
Name: Versions (Products can have one or more versions eg. red and blue)
Fields: ID, Product_ID
Name: Orders (Contains all info about orders eg. timestamp, customer info)
Fields: ID, Timestamp
Name: Ordered_Items (This contains the info about which product versions were bought on each order)
Fields: Version_ID, Order_ID, Quantity
What I need to do is find the total number of each version sold since a particular time.
Here is what I have but it seems to ignore the timestamp given and just find all that have ever been sold.
SELECT SUM(oi.`Quantity`) AS `Quantity`
FROM `Products` AS p
JOIN `Versions` AS v ON v.`Product_ID` = p.`ID`
LEFT JOIN `Ordered_Items` AS oi ON oi.`Version_ID` = v.`ID`
LEFT JOIN `Orders` AS o ON o.`Timestamp` > 13044862257 && o.`ID` = oi.`Order_ID`
WHERE p.`ID` = 212
GROUP BY m.`ID`
The reason for the left joins is because in the actual query I also get other fields from the versions table but there may not have been any ordered.
Any help would be greatly appreciated.