我有3个表SQL
如何转换PHP和& MYSQL将表产品名称列添加到列中,并获取所有客户行的组id_product sum(quantity_data)。
谢谢..
我使用SQL
SELECT
data_prodcuts.id_product,
sum(data_prodcuts.quantity_data) as total,
data_prodcuts.id_customer,
products.name_product,
customers.name_customer
FROM data_prodcuts
LEFT JOIN products ON products.id = data_prodcuts.id_product
LEFT JOIN customers ON customers.id = data_prodcuts.id_customer
GROUP BY name_product, name_customer