Answer the question
In order to leave comments, you need to log in
How to display data from one table, while using 2 more tables for the query?
Here is such an output structure, how to make such a multiple sql output?
1. Order table - List of orders .
2. Table order_product - Products added to the order.
3. Products table with all products and data.
Заказ #1 - Дата - Оплачен\Не оплачен - Сумма всего
--Товар 1 - Количество - сумма
--Товар 2 - Количество - сумма
Заказ #2 - Дата - Оплачен\Не оплачен - Сумма всего
--Товар 1 - Количество - сумма
--Товар 2 - Количество - сумма
SELECT
shop_order.id AS id_order,
shop_order.name AS name_order,
shop_order.adress,
shop_order.phone,
shop_order.status,
order_product.product_count,
product.name AS name_product,
product.price,
SUM(product.price) AS sum_total
FROM
bot_shop_order_product order_product
INNER JOIN bot_shop_order shop_order ON
shop_order.id = order_product.parent_id
INNER JOIN bot_shop_product product ON
product.id = order_product.parent_id
WHERE
order_product.magazin = 26
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question