我有幾千個特許經營權,以及大約3或4個服務組。服務組在一個單獨的表格中,然後我有第三個表格將它們連接在一起。一個特許經營權可以連接到一個或多個服務組。我試圖達到的目標是列出特許經營權,列有「服務類別」欄。然後它將以逗號分隔列出他們提供的服務。所以,現在,這裏是我的輸出:將列中的值彙總/連接成單行
id Service Groups name email address City State
1 Cleaning Services Franchise of LocationX [email protected] 123 Fake st. Springfield TheOneTheSimpsonsLiveIn
2 Disaster Services Franchise of LocationX [email protected] 123 Fake st. Springfield TheOneTheSimpsonsLiveIn
我想使它成爲這個有它:
id Service Groups name email address City State
1 Cleaning Services, Disaster Services Franchise of LocationX [email protected] 123 Fake st. Springfield TheOneTheSimpsonsLiveIn
我可以用它來做到這將是greately任何建議或方法/函數的引用讚賞。謝謝!
你可以看看這個http://stackoverflow.com/questions/6344950/sql-query-to-get-aggregated-result-in-comma-seperators-along -with-group-by-column/6349132#6349132 – EricZ
或者這一個:http://stackoverflow.com/questions/1874966/concatenate-row-values-t-sql –
可能的重複[在MS SQL中模擬group_concat MySQL函數Server 2005?](http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005) –