I have two tables:
CREATE TABLE `marks` (
`id_student` int(11) NOT NULL default '0',
`id_subject` int(11) NOT NULL default '0',
`mark` tinyint(4) NOT NULL default '0'
);
CREATE TABLE `subjects` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
);
`marks` table contains the list of marks for all students, the `id_student` field is connected with `id` from `subjects` table. What I need to do is to create a view with marks of specified student, something like:
| subject_id | marks |
| 1 | 1,2,3,4 |
| 2 | 2,2,2,5,4 |
| 3 | 5,5,6 |
...
I know I can handle that with GROUP_CONCAT, but what about earlier versions of MySQL? Can it be done with temp variables and CONCAT_WS function? I tried, but failed. This is not a homework, I just want to know if there is a solution for earlier MySQL versions and that sample seems to be the easiest one to show on.
Thanks.
by: akshah123Posted on 2005-09-11 at 08:06:59ID: 14859359
I don't think you can do what you want to do with concat_ws only (at least not in just one query). However, if you are running mysql on windows box. Check out:
/Purgatory /mygroupco ncat.asp
http://www.codeproject.com