Return all items and indicate if a relationship exists?
Posted on 2008-10-10
I have three tables: Upgrades, Projects, and a relationship table that acts as relationship table(many to many) we will call it rel_Projects_ProjectUpgrades
In the rel_Projects_ProjectUpgrades table i have the primary keys for the Upgrades and Projects table. One project may have several upgrades. How can I write the SQL to show me all the upgrades available and indicate which ones are associated with a project? I have been racking my brain on this. Thank you
Here is what I tried:
RIGHT OUTER JOIN dbo.rel_Projects_ProjectUpgrades ON (dbo.Projects.projectID = dbo.rel_Projects_ProjectUpgrades.projectID)
RIGHT OUTER JOIN dbo.ProjectUpgrades ON (dbo.rel_Projects_ProjectUpgrades.projectUpgradeID = dbo.ProjectUpgrades.projectUpgradeID)
I don't get anything back. I tried goign the other way (selecing from Projectupgrades) using a left join