Avatar of taz8020
taz8020
Flag for United Kingdom of Great Britain and Northern Ireland asked on

sql top 6 keywords to comma separated string

Hi I have an sql table like


productId        keyword        order

1                        keyword1      1
1                        keyword2      2
1                        keyword3      3
1                        keyword4      4
1                        keyword5      5
1                        keyword6      6

I want to do a inner join query to my products and want one column to be
"keyword1,keyword2,keyword3,keyword4,keyword5,keyword6"

if there are only 3 I don't want all the extra comma and ideally if keyword2 is missing just uses the next keyword etc.
Microsoft SQL Server 2005Microsoft SQL Server 2008Microsoft SQL Server

Avatar of undefined
Last Comment
taz8020

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
taz8020

ASKER
AMAZING!!!!!!!!!!!!!!!!!!!!!
Thank you just what I was after
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck