Having a student and subject table. Is it possible that by only using MySQL I can combine the values in one field as comma separated.
Student table
sid | subject_id
1 | 1,2
2 | 1
3 | 2
4 | 1,2,3
Subject Table
subject_id | subject_name
1 | Maths
2 | Sci
3 | Eng
4 | Eco
Required Result
sid | subject_name
1 | Maths,Sci
2 | Maths
3 | Sci
4 | Maths,Sci,Eng
Code I tried
SELECT
student_table.sid,
GROUP_CONCAT(
subject_table.subject_name
)
FROM
student_table
LEFT JOIN
subject_table ON student_table.subject_id = subject_table.subject_id