itâs an aggregate query without GROUP BY clause. Better specify what you want there (probably GROUP BY ordernumber). IIRC in strict mode MySQL wonât execute any aggregate query without a GROUP BY clause.
you canât actually call a table order as itâs a reserved keyword. Youâd have to quote it in backticks
ordernumber, quantity and product might be ambiguous. Better to specify which table you want them from (orderid possibly also, though less nasty because both orderid and order.id appear in the ON clause)
maybe the intent of the query was to get all orders with less than 10 items total, in which case it should be HAVING SUM(quantity) < 10 rather than WHERE quantity < 10
well spotted â orderitem would have only one row per product in an order
summing product quantities within an order might make sense, if only it wasnât for that pesky âwidgetâ filter, which negates that need
as for the âless than 10â criterion, thatâs fine â suppose i wanted to see orders for low quantities, when people usually order my products by the hundreds
Then you wouldnt sum them⌠(so again, its that abiguous nature of what was written - is it meant to be a sum of orders (which doesnt fit the brief), or is it meant to be a sum within the order (which doesnt make sense given the nature of an order)âŚ