Let's say I have this tables in MySQL:
Courses: id, name
Students: id, name
CoursesStudents: idCourse, idStudent
I can do:
SELECT c.id, cs.idStudent
FROM Courses C, CoursesStudents cs
WHERE c.id = cs.idCourse
For every course I will get some rows of the students that attend that course.
How can I transform the query to return just one row per course, and in the second column the list of id's students? Something like:
course1 st1, st2, st3
course2 st4, st5
course3 st7
...
If it is posible, how can I do that using squeryl library in Scala?
Edit:
I found how to do it in plain SQL using "GROUP_CONCAT":
SELECT c.id, GROUP_CONCAT(cs.idStudent)
FROM Courses C, CoursesStudents cs
WHERE c.id = cs.idCourse
GROUP BY c.id