0
我想做一些statisctics。我的數據庫看起來像這樣:PHP的SQL查詢沒有foreach簡單的方法
+----+------------+------------+------------+--------------+
| id | value1 | value2 | value 3 | year |
+----+------------+------------+------------+--------------+
| 1 | something1 | something3 | something5 | 2016 |
| 2 | something2 | something3 | something6 | 2015 |
| 3 | something1 | something4 | something5 | 2014 |
| 4 | something1 | something4 | something6 | 2016 |
| 5 | something2 | something3 | something5 | 2014 |
+----+------------+------------+------------+--------------+
我的問題是如何構建儘可能查詢的查詢,或計算數值,並返回其下方具有結構數組一樣簡單?
[0] =>
['year'] => 2014
['value1'] =>
['something1'] => 1
['something2'] => 1
['value2'] =>
['something3'] => 1
['something4'] => 1
['value3'] =>
['something5'] => 2
[1] =>
['year'] => 2015
['value1'] =>
['something2'] => 1
['value2'] =>
['something3'] => 1
['value3'] =>
['something6'] => 1
[2] =>
['year'] => 2016
['value1'] =>
['something1'] => 2
['value2'] =>
['something3'] => 1
['something4'] => 1
['value3'] =>
['something5'] => 1
['something6'] => 1
'count'會做.. – Fil
地獄,一個循環會做。 – Strawberry