Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Dobly
Starting Member
16 Posts |
Posted - 2010-09-02 : 18:47:15
|
| OH, this one is doing my head in. I am doing query that will tell if if a User has Access to a Location via the Territory each is in. Sounds simple enough but here's the details. A Location can be in one or many Territories. A User can be assigned to one or many Territories. The tables look like this. LocationLocationID (PK)LocationTerritoryLocationID (FK)TerritoryID (FK)TerritoryTerritoryID (PK)UserTerritoryUserID (FK)TerritoryID (FK)UserUserIDSo if a Location is in Territories 3, 4 and 5and a user is assigned to Territories 5, 6 and 7That would match as Territory 5 is common to both. If the user is assigned to Territories 6, 7 and 8, no match would be made. I should add that a user might not be assigned to any Territories. Likewise a Location might not be in any Territories. This might be really simple but at the moment I just can't see it. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Dobly
Starting Member
16 Posts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|