Ok, so I am dealing with 4 tables here – Project, Members, Iterations and ProjectIterationMembers. When I create new project details, I am writing them to the Project table and I am also specifying an iteration (start date, end date – a project consists of at least one iteration, but more iterations can be added afterwards). Members from the Members table are now written to the ProjectIterationMembers table as they are assigned to iterations.
What I am trying to do is display project details in a datagridview in this format:
Project Name | Project Manager | Project Status
Project A | Person A | In Progress
Project B | Person B | In Progress
However, my output is this for some reason when I add a new project or new iterations:
Project Name | Project Manager | Project Status
Project A | Person A | In Progress
Project A | Person B | In Progress
Project B | Person A | In Progress
Project B | Person B | In Progress
Here is my sql statement and thanks for your help:
SELECT
DISTINCT(Project.ProjectName),
Project.ProjectID,
Project.Status,
Project.CompanyID,
Project.StartDate,
m.MemberID,
m.FirstName + ' ' + m.LastName AS ProjectManager
FROM
Project,
Member m,
ProjectIterationMember
WHERE
m.CompanyRole = 'Project Manager'
AND Project.CompanyID = '" + co_id + "'
AND m.MemberID = ProjectIterationMember.MemberID
ORDER BY
Project.StartDate DESC
As far as i see from your sql, you are probably missing a join between tables Project and ProjectIterationMember and you get cartesian join.
I can’t help you more then this since i have no idea what your ER diagram or at least table definitions look like.
edit: from your ERD, here is how from and where should look like: