I have a list of employees (EmployeeID, EmployeeName, etc) I have a list of Projects (ProjectID, ProjectName, etc) This is a many to many relationship - a project can have many employees working on it and an employee can be working on many projects.
This much is okay. Currently I've done
SELECT Employee.EmployeeID, ProjectEmployee.ProjectID
FROM Employee LEFT JOIN
ProjectEmployee ON Employee.EmployeeID = ProjectEmployee.EmployeeID LEFT JOIN
Projects ON ProjectEmployee.ProjectID = Projects.ProjectID
This currently returns all employees whether or not they are assigned to a project. If they are assigned to multiple projects, their ID appears in column 1, twice. e.g.
EmployeeID ProjectID
1 NULL
2 1
3 1
4 1
4 2
5 1
6 2
7 2
I don't know if it's possible but I'd like it to list all employees once in column one. If they are assigned to multiple projects, list all the projects in a single field in column 2 e.g.
EmployeeID ProjectID
1 NULL
2 1
3 1
4 1,2
5 1
6 2
7 2
Thanks in advance for any advice!