group_concat函數是在mysql4.1版本被加進的函數,其作用是把分類查詢後的值連接。
所以該函數必須要和group一起使用才能獲得正確結果。具體用例如下
id | value |
1 | a |
1 | b |
1 | c |
1 | d |
2 | e |
2 | f |
2 | g |
3 | h |
select id,group_concat(value) from table1 [ where 1<2 ] group by id;
結果
id | group_concat(value) |
1 | a b c d |
2 | e f g |
3 | h |
該函數通常用來做處理資料彙總之目的。