List:General Discussion« Previous MessageNext Message »
From:Josh Mellicker Date:December 24 2005 10:23am
Subject:MySQL query question
View as plain text  
I have several tables, all with many-to-many joining tables.

users

users_teams

teams

teams_projects

projects


---

So, with a projects.id = 1, I want to get all the usernames of people  
on teams assigned to that project.

SELECT DISTINCT username
FROM users, users_teams, teams, projects_teams, projects
WHERE projects.id = '1'
AND projects_teams.project_id = projects.id
AND teams.id = projects_teams.team_id
AND users_teams.user_id = users.id

gives me ALL the users who are on any team... even teams not assigned  
to that project.

What gives? My brain hurts. Thanks for any help.
Thread
MySQL query questionJosh Mellicker24 Dec
  • Re: MySQL query questionHank24 Dec
  • Re: MySQL query questionPeter Brawley24 Dec