I need to query 3 tables with a many to many relationship:
Players Table Ta:
PlayerID PlayerName
1 p1
2 p2
Format Table Tb:
FormatID FormatName
1 mp3
2 wmv
3 wav
WhatPlayerPlaysWhatFormat Table Tc:
WPWFPlayerID WPWFFormatID (both foreign keys)
1 1
1 2
2 1
2 2
3 3
Now I want a query that shows all the formats that a player can play. I'm thinking about something like this:
SELECT Ta.PlayerID,Ta.PlayerName,Tb.FormatName
FROM Ta,Tb,Tc
WHERE Ta.PlayerID=Tc.WPWFPLayerID AND Tc.WPWFFormatID=Tb.FormatID
GROUP BY Ta.PlayerID
But since the Tb.FormatName will have multiple matches, I need some function to concatenate all the formats in one row. I don't know if there's such a function, or am I using the wrong approach?
Please help. Thanks.
Players Table Ta:
PlayerID PlayerName
1 p1
2 p2
Format Table Tb:
FormatID FormatName
1 mp3
2 wmv
3 wav
WhatPlayerPlaysWhatFormat Table Tc:
WPWFPlayerID WPWFFormatID (both foreign keys)
1 1
1 2
2 1
2 2
3 3
Now I want a query that shows all the formats that a player can play. I'm thinking about something like this:
SELECT Ta.PlayerID,Ta.PlayerName,Tb.FormatName
FROM Ta,Tb,Tc
WHERE Ta.PlayerID=Tc.WPWFPLayerID AND Tc.WPWFFormatID=Tb.FormatID
GROUP BY Ta.PlayerID
But since the Tb.FormatName will have multiple matches, I need some function to concatenate all the formats in one row. I don't know if there's such a function, or am I using the wrong approach?
Please help. Thanks.