To calculate a total amount for an order, I go to the articles table, and calculate the sum of the articles for this order.
Here is my code:
SELECT orders.*,
ROUND(SUM(`orders_article_updated_quantity` * (`orders_article_price` * (100 - orders_article_rate)/100)), 2) AS 'order_Total'
FROM orders JOIN orders_articles
ON orders.order_id = orders_articles.orders_article_id_order
WHERE oreder_id = '" . $order['order_id'] . "'
This code is working for an order, and I got a good result.
Now I want to do this for a list of orders, or all orders. So I deleted the "WHERE" from my request. And I get only one result, with the sum of all orders.
For each result (order), I want the sum of its own articles.