group_concat函數

group_concat函數是在mysql4.1版本被加進的函數,其作用是把分類查詢後的值連接。

所以該函數必須要和group一起使用才能獲得正確結果。具體用例如下

表table1
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

 該函數通常用來做處理資料彙總之目的。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章