Link to home
Start Free TrialLog in
Avatar of Lee W, MVP
Lee W, MVPFlag for United States of America

asked on

Concat multiple records into one line

Lets say you have a table:
Name   City            Date
Bob      Anytown   2017-03-15
Bob      Anytown   2017-03-21
Jim       Sometown 2017-02-27
John    Mytown      2017-03-06
John    Mytown      2017-03-19
John    Mytown      2017-03-25

I need to query the table so that my results are as follows:
Name  City            Dates
Bob     Anytown    2017-03-15,2017-03-21
Jim      Sometown 2017-02-27
John    MyTown     2017-03-06,2017-03-19,2017-03-25

I guess I'm asking how can I (can I?) have the results of a single field query reported in a single row rather than multiple rows?

Thoughts?  

I know how I can use a programming language to manipulate this (VB/ASP for example), with looks, but I'm looking for a pure SQL way.  IDEALLY MySQL way.
ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lee W, MVP

ASKER

Worked great - happy client.  Thanks!
You're welcome.

Glad I could help!