2016-05-25 44 views
0

是否有可能,有選擇查詢,要達到這樣的的MySQL,在SELECT結果組行

| firstfield | secondfield | types 
    firstvalue secondvalue 1,2,3 

而不是

| firstfield | secondfield | type 
    firstvalue secondvalue 1 
    firstvalue secondvalue 2 
    firstvalue secondvalue 3 

感謝您的幫助。

回答

1

您可以使用group_concat

select firstfield, secondfield, GROUP_CONCAT(type order by type) as types 
from yourtable 
group by firstfield, secondfield;