The oracle wm_concat (column) function is frequently used. The following describes how to use the oracle wm_concat (column) function to merge fields. If you use the oracle wm_concat (column) function) if you are interested in function usage, take a look.
Shopping:
-----------------------------------------
U_id goods num
------------------------------------------
1 Apple 2
2 pears 5
1 watermelon 4
3 grape 1
3. Banana 1
1 orange 3
======================================
The expected result is:
--------------------------------
U_id goods_sum
____________________
1 Apple, watermelon, orange
2 pears
3 grapes, bananas
---------------------------------
1. select u_id, wmsys. wm_concat (goods) goods_sum 2. 3. from shopping 4. 5. group by u_id
Expected result 2:
--------------------------------
U_id goods_sum
____________________
1 Apple (2 kg), watermelon (4 kg), orange (3 kg)
2 Pears (5 kg)
3 grapes (1 kg), bananas (1 kg)
---------------------------------
Use the oracle wm_concat (column) function:
Select u_id, wmsys. wm_concat (goods | '(' | num | 'jin) ') goods_sum
From shopping
Group by u_id
Mysql --- group_concat