GROUP_CONCAT ORDER BY GROUP_CONCAT ORDER BY mysql mysql

GROUP_CONCAT ORDER BY


You can use ORDER BY inside the GROUP_CONCAT function in this way:

SELECT li.client_id, group_concat(li.percentage ORDER BY li.views ASC) AS views, group_concat(li.percentage ORDER BY li.percentage ASC) FROM li GROUP BY client_id


The group_concat supports its own order by clause

http://mahmudahsan.wordpress.com/2008/08/27/mysql-the-group_concat-function/

So you should be able to write:

SELECT li.clientid, group_concat(li.views order by views) AS views,group_concat(li.percentage order by percentage) FROM table_views GROUP BY client_id


Try

SELECT li.clientid, group_concat(li.views ORDER BY li.views) AS views,       group_concat(li.percentage ORDER BY li.percentage) FROM table_views li GROUP BY client_id

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function%5Fgroup-concat