假設有一個資料表TopicItem :
想要看VideoId有哪些TopicId, 所以想組合成:
語法 :
select
VideoId,
STUFF
(
(
select DISTINCT ',' + convert(varchar(10),TopicId) from TopicItem where VideoId = a.VideoId
FOR XML PATH ('')
), 1, 1, ''
) as Topics
from TopicItem a
group by VideoId
沒有留言:
張貼留言