Concatenate multiple columns into one column (,) separated In SQL database that stores Images in a parcelImages table.Since each parcel can take part in multiple Images and each images can involve multiple parcels.



I want to get each parcel having Image value with comma separated values as shown above

I tried with this SQL Query 

SELECT ParcelId,id,concat(ParcelId, ' ', id) 
FROM ParcelImages 
WHERE Id IN (43418,43464,43465,43466,43467,43470,43471,43482,43483)


but expected result not get. How can this be done?

I have also tried an INNER JOIN How can I achieve this, I'm kinda stuck at the early beginning.

If there is a table called STUDENTS

ID                     StudentName                                                      
----------             -------------                                                      
1                      Mary                                                      
1                      John                                                      
1                      Sam                                                      
2                      Alaina                                                      
2                      Edward                                                        


Result I expected was:

ID              StudentName                                                      
----------      -------------                                                      
1               Mary, John, Sam                                                      
2               Alaina, Edward
I think you need to use GROUP CONCAT (only available in MySQL). If you are using MS SQL Server you can try this project: https://groupconcat.codeplex.com/