我已經a table這樣的:GROUP_CONCAT ORDER BY
+-----------+-------+------------+
| client_id | views | percentage |
+-----------+-------+------------+
| 1 | 6 | 20 |
| 1 | 4 | 55 |
| 1 | 9 | 56 |
| 1 | 2 | 67 |
| 1 | 7 | 80 |
| 1 | 5 | 66 |
| 1 | 3 | 33 |
| 1 | 8 | 34 |
| 1 | 1 | 52 |
我試圖group_concat
:
SELECT li.client_id, group_concat(li.views) AS views,
group_concat(li.percentage) FROM li GROUP BY client_id;
+-----------+-------------------+-----------------------------+
| client_id | views | group_concat(li.percentage) |
+-----------+-------------------+-----------------------------+
| 1 | 6,4,9,2,7,5,3,8,1 | 20,55,56,67,80,66,33,34,52 |
+-----------+-------------------+-----------------------------+
但我想爲了看法,如:
+-----------+-------------------+----------------------------+
| client_id | views | percentage |
+-----------+-------------------+----------------------------+
| 1 | 1,2,3,4,5,6,7,8,9 | 52,67,33,55,66,20,80,34,56 |
+-----------+-------------------+----------------------------+
是以逗號分隔值存儲的表中的視圖值和百分比值? – Virendra 2011-12-25 19:44:29
不,他們不是那樣存儲,但我通過我的查詢,即與group_concat – ronquiq 2011-12-25 19:46:52
[MySQL:排序GROUP \ _CONCAT值]可能的重複,使他們(http://stackoverflow.com/questions/995373/mysql-sort- group-concat-values) – outis 2013-01-30 22:38:37