I have this query below:
SELECT q.QuestionId,GROUP_CONCAT(DISTINCT Answer SEPARATOR '') AS Answer
FROM Question q
INNER JOIN Answer an ON q.QuestionId = an.QuestionId
GROUP BY an.QuestionId
NOw where you can see in my select statement I have this field (DISTINCT Answer SEPARATOR '') AS Answer. Now lets say in the output it outputs this below:
Answer
ECB
FDA
I want the Answers to be ordered in alphabetical order so that it displays its like below:
Answer
BCE
ADF
Does anyone know what I need to change in the SQL in order to acheieve this?
It’s sometimes useful to read the documentation. MySQL GROUP_CONCAT
Do have a look at using something sensible as SEPARATOR rather than ” (nothing), otherwise your answers get mashed together.