对于改善广告公司工作流程的项目,您可以使用不同的表进行查询,这些表被使用:
clients: Contains ID, business, lastname, name, addresse, city and zoneID etc
lookupClients: ID, clientID, productID, date, part1, part2, sizeID, design, quant
lookupPrices: ID, productID, sizeID, price
products: ID, artname, image, category
size: ID, size, width, height
为了获得我需要的信息,你做了以下 SQL 查询
SELECT products.ID AS PID, clients.zoneID AS ZID, clients.business, clients.address, size.size, lookupClients.quant, lookupClients.date, lookupClients.part1, lookupClients.part2, lookupPrices.price
FROM lookupClients, lookupPrices, clients, products, size, zone
WHERE lookupClients.clientID = clients.ID
AND lookupClients.sizeID = lookupPrices.sizeID
AND lookupClients.sizeID = size.ID
AND lookupClients.productID = products.ID
AND lookupPrices.productID = products.ID
AND clients.zoneID = zone.ID
ORDER BY clients.zoneID, lookupClients.sizeID, clients.business
到目前为止,这个查询工作正常,我用它在 mysql 中构建一个视图。但问题是,当您想要构建此视图的总和并对列 part1、part2 和 price 求和时,mysql 返回完全错误的结果。有没有人想改进这个查询以获得正确的总和?
感谢您的帮助。