GROUP_CONCAT problem

Hi guys,

I was wondering if someone could help me. I have the following tables:

task_objectives
objectiveid taskid name description

task_objective_users
ID objectiveid userid

users
userid username

I am trying to display the users for each objective. My query is


SELECT task_objectives.name, task_objectives.description, GROUP_CONCAT(users.username) as users FROM task_objectives
LEFT OUTER JOIN task_objective_users ON task_objective_users.objectiveid = task_objectives.ID
LEFT OUTER JOIN users ON users.ID = task_objective_users.userid
WHERE task_objectives.taskid = 1

However this doesn’t work since it just merges all the task_objectives into one string. Is there a way to get all the users with a single query?

Thanks for any help!

add this to the end of your query –

GROUP BY task_objectives.name

Ah thank you! I knew I was missing something!