我有试图在下表中结合了MySQL查询帮助:需要一个MySQL查询
TABLE: orders_products
products_id
orders_id
products_quantity
products_price
TABLE: products
products_id
products_model
我想返回销售总数的查询,对每个PRODUCT_ID销售总额,以及orders_products表中每个产品的product_model。这是我想出来的迄今最好的,它只是增加了什么东西都往同一桶:
SELECT
SUM(op.products_quantity) AS num_sold
,SUM(op.final_price * op.products_quantity)
,p.products_model
FROM orders_products AS op
JOIN products AS p
WHERE p.products_id = op.products_id
+1因为我喜欢它 – Smandoli 2011-04-15 04:13:11
谢谢!我已经做了足够的查询,我应该知道这一点。 – user77413 2011-04-15 04:22:23
@ user77413欢迎您 – Wes 2011-04-15 04:28:43