1
我的查詢:如何總結行的數據具有相同的ID
"SELECT sent_who, sent_amount FROM game1 ORDER BY sent_who ASC;"
輸出:
array (size=4)
0 =>
array (size=4)
'sent_who' => string '1' (length=1)
0 => string '1' (length=1)
'sent_amount' => string '1' (length=1)
1 => string '1' (length=1)
1 =>
array (size=4)
'sent_who' => string '2' (length=1)
0 => string '2' (length=1)
'sent_amount' => string '1' (length=1)
1 => string '1' (length=1)
2 =>
array (size=4)
'sent_who' => string '2' (length=1)
0 => string '2' (length=1)
'sent_amount' => string '1' (length=1)
1 => string '1' (length=1)
3 =>
array (size=4)
'sent_who' => string '2' (length=1)
0 => string '2' (length=1)
'sent_amount' => string '1' (length=1)
1 => string '1' (length=1)
我想要什麼:
array (size=4)
0 =>
array (size=4)
'sent_who' => string '1' (length=1)
0 => string '1' (length=1)
'sent_amount' => string '1' (length=1)
1 => string '1' (length=1)
1 =>
array (size=4)
'sent_who' => string '2' (length=1)
0 => string '2' (length=1)
'sent_amount' => string '3' (length=1)
1 => string '1' (length=1)
我想在陣列合併相同sent_who
,也在同一陣列中加上sent_amount
。 如果我使用GROUP BY而不是ORDER BY它適用於sent_who,但它不給出sent_amount