恐怕我已经写了一个查询并且在这个过程中让自己感到困惑,尽管它很简单。
我有 2 个 mysql 表。
Table1 has ... orderID, productID, quantity
Table2 has ... orderID, status, time
我需要做一个查询,它将执行以下操作......
Output (1 per line)
productID - Quantity where status = 1 & time < $lastactive.
我尝试对表 2 进行查询以获取 productID 并计算 Quantity,但是如果 2 个不同的 orderID 具有相同的 productID,则它们不会总计。非常感谢任何帮助(表/行的名称是准确的)。
例子:
orderID 123, productID 2, quantity 4
orderID 123, productID 5, quantity 6
orderID 678, productID 2, quantity 5
会输出:
2 9
5 6