I have three database tables - one containing units, one containing categories of those units, and one containing user permissions.
If a user can access a category, they are allowed to access any units within the category.
I am trying to create a query that will retrieve a list of units they are allowed to access. So far I have a very awkward query that returns duplicates, and am a bit stuck, and it's Friday afternoon, and I wanna go home!
Here are my tables:
UnitCategory
categoryid unitid
Unit
id name
UnitCategoryUser
unitid userid categoryid
- can be null - can be null
Thanks