試してみてください:
SELECT a.name,a.email, GROUP_CONCAT(c.code)
FROM users a
JOIN code_to_user_ref b ON a.user_id = b.user_id
JOIN codes c ON b.code_id = c.code_id
GROUP BY a.name,a.email
結果は次のようになります:
| NAME | EMAIL | CODE/S OWNED |
|------|--------------|---------------|
| jane | [email protected] | Vb#4%6 |
| joe | [email protected] | [email protected]$5,[email protected]$ |
| john | [email protected] | Bn%6&8 |
こちらが