I have a question, I want to join the table with comma, but if use normal method to join the table, it cannot get the correct data in the table. I am using MySQL 1.1.20 version. Below is my sample scenario:
I have two tables, table structure like below:
First Table name: student
id | name | course_id
——————————————————————————
1 David 1,3
2 Peter 2,4
3 Shawn 2,6
Second Table name: subject
id | subject
———————————————————
1 English
2 Maths
3 Science
4 Geographic
5 Accounting
6 Art & Design
I want the actual result like below:
id | name | subject_name
——————————————————————————
1 David English,Science
2 Peter Maths,Geographic
3 Shawn Maths,Art & Design
I have use below normal method to join two table, but I don't know how to join if got comma in the column.
SELECT s.id as id,s.name as name,sub.subject as subject_name from student s left join subject sub on s.course_id = sub.id
Hope someone can guide me on how to solve this problem. Thanks.
MySql query browser version: