I have a SQL question, and hope someone could help me or give me some pointers. Much appreciated.
I have two tables: A and B.
- A has columns
IDwhich is the primary key field, andNAME - B has columns
DUPID,NAMEandIDwhich is the primary key
The relationship between A and B is in B, the DUPID contains certain values of A.ID, and the request is to append distinct B.NAME value to A.NAME separated by semi-colon based on join A.ID = B.DUPID..
Maybe my explanation isn't clear, here is a simple example.
A B
ID NAME DUPID NAME
1 null 1 John
2 null 1 John
3 null 1 Mark
4 null 3 Luke
5 null 3 Luke
3 Luke
3 Matthew
So eventually, I will need to update table A, and make it look like below
A
ID NAME
1 John;Mark
2 null
3 Luke;Matthew
4 null
5 null