कोशिश करें:
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 |
यह रहा SQLFiddle .