Home > database >  Looking for a great god, and mysql orders and goods list query problem, an order contains more than
Looking for a great god, and mysql orders and goods list query problem, an order contains more than

Time:09-17

As title, order table order (phone), order goods form the detail (order_id, goods_id, price_sell, amount),
Now according to the order table some of the fields and the detail list of fields query order information,
If only according to the detail list of goods_id query so DISTINCT,

The question now is, I want real goods_id=1 the subtotal amount of (amount * price_sell) are also displayed,

Did not for a long time,

CodePudding user response:

The easiest way to write two SELECT, a detailed, a subtotal, then UNION ALL together,

CodePudding user response:

reference 1st floor AHUA1001 response:
the easiest way to write two SELECT, a detailed, a small program, and then UNION ALL together,

Could you use an example

CodePudding user response:

Grouped together and then the results as the new table by table can be realized

CodePudding user response:

reference 3/f change the pain response:
grouped together and then the results as a new table by table can realize

Eldest brother, can you help me write my bai directly

CodePudding user response:

Select * from a, b, (select goods_id, sum (amount) * price_sell from group b) where a. c *=b. *, b.g oodsid be sad oodsid chtistina georgina rossetti.british poetess=

CodePudding user response:

refer to fifth floor metamorphosis of pain response:
select * from a, b, (select goods_id, sum (amount) * price_sell from group b) where a. c *=b. *, b.g oodsid be sad oodsid chtistina georgina rossetti.british poetess=

You this not line, an error

CodePudding user response:

My short , to provide a train of thought,
SELECT
B. a. *, *, c.p rices
FROM the ORDER a, the detail b,
(
The SELECT goods_id, sum (amount) * price_sell AS prices
The FROM
The detail GROUP
C)
WHERE Anderson, d=b.o rder_id and b.g oods_id be sad oods_id chtistina georgina rossetti.british poetess=
  • Related