Answer the question
In order to leave comments, you need to log in
How to correctly build a query from three tables?
There are three tables: Goods, Orders,
GoodsOrdersRelationshipItemsOrdersRelationship contains only IDs of Goods linked to Orders.
Products
Answer the question
In order to leave comments, you need to log in
SELECT
ol.order_id `Номер заказа`,
c.name `Клиент`,
count(ol.goods_id) `Всего позиций`,
sum(ol.amount) `Кол-во товаров`,
sum(g.cost) `Общая сумма`
FROM
order_list ol,
goods g,
`order` o,
client c
WHERE
g.id=ol.goods_id
AND
o.id=ol.order_id
AND
c.id=o.client_id
GROUP BY ol.order_id;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question