Any ideas how to proceed with this? Tried some group by’s without success. Or would it be wiser to select the rows as seen in the picture and process it in the code instead of doing it in SQL? I am using MySQL.
I’ll try to explain the reason behind the concatenating. When user gives answer “4” for example for some course (c_id, in this case 27838263) he can choose the events belonging to this c_id and the same answer will be saved for each chosen event for the course (c_id).
So I have two snenarios where I need to pull data from this table. Per event answers, which is easy just using the event number for that.
And the second scenario where I have to distinguish answers given for the whole course (for example the most upper answer set in the picture I do not want 5 x “4” answers, I only want one “4” for one question and one user for the course). For this purpose I concencate the c_id, question_id and user_id fields, which gives me one answer row per user, per question per course (using DISTINCT in the select now to get the desired result). Not sure if this makes more sense
No. Did you try without the concat? The DISTINCT already does what you want, the concat has nothing to do with it (since it contains the same three fields you already select.