troubleshooting Question

add comma-delineated column into SQL output

Avatar of Evan Cutler
Evan CutlerFlag for United States of America asked on
Microsoft SQL Server 2005Microsoft SQL Server 2008
2 Comments1 Solution401 ViewsLast Modified:
I have this SQL:
      SELECT A.PK, A.Title, LEFT(A.Text, 25) + '...', a.date_entered, C.Concentration
      from Advertisements A
      join  [Concentration-Advertisement] CA
      ON A.PK = CA.FK_Advertisement
      join Concentrations C
      ON CA.FK_Concentration = C.PK;

the C.Concentration field lists the field that the Advertisement is associated with.
what happens is rows repeat Advertisement info, because it is a 1 to many ratio.

Instead, I want the C.Concetration to represent a comma-delineated list of the concentrations for one row per advertisement.

Below is the table reference...
Advertisement
============
PK, Title, Text, Date

Concentration-Advertisement
========================
PK, FK-C, FK-A

Concentration
===========
PK, Concentration

Thank you.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros