0

I have one table in MS access 2016.

enter image description here

If the ID is same for two rows, I want to merge the Code & Course columns into single columns.

So the output should be

enter image description here

I have tried functions like STUFF, FOR XML PATH etc which seems to be not compatible with MS Access.

Any help is greatly appreciated.

Raj Kumar
  • 953
  • 1
  • 8
  • 19

1 Answers1

0

In MySQL there is the GROUP_CONCAT aggregate function that does exactly what you are looking for, but not in Access SQL.

The only way to do that is using VBA code. You can take a look here:

http://allenbrowne.com/func-concat.html

Allen Browne wrote a function in VBA to get that result.

In Access you can call VBA functions in your SQL code, so this could be the solution:

SELECT ID,  
       ConcatRelated("Code", "tableName", "ID = " & [ID]),
       ConcatRelated("Course", "tableName", "ID = " & [ID]) 
FROM tableName;
kiks73
  • 3,718
  • 3
  • 25
  • 52