基於ID 連接值
要解決所提供的組合具有相同ID 的多行並連接相應標籤的任務,請使用以下標籤SQL查詢:
declare @T table(Response_ID int, Label varchar(50)) insert into @T values (12147, 'It was not clear'), (12458, 'Did not Undersstand'), (12458, 'Was not resolved'), (12458, 'Did not communicate'), (12586, 'Spoke too fast'), (12587, 'Too slow') select T1.Response_ID, stuff((select ','+T2.Label from @T as T2 where T1.Response_ID = T2.Response_ID for xml path(''), type).value('.', 'varchar(max)'), 1, 1, '') as Label from @T as T1 group by T1.Response_ID
在查詢:
以上是如何在 SQL 中根據匹配 ID 連線標籤?的詳細內容。更多資訊請關注PHP中文網其他相關文章!