Person Name | Gadgets |
---|---|
Amy | LG, Samsung, Sony |
Bea | Blackberry, iPhone |
select p.name as "Person Name", STUFF(( SELECT ',' gadget_name FROM gadget g WHERE p.person_id = g.person_id FOR XML PATH('')), 1, 1, '') as "Gadgets" from person
Concatenation is done by the FOR XML PATH; whereas the STUFF is to simply remove the first comma (",").
No comments:
Post a Comment