Solved

selecting across multiple tables to check permission

Posted on 2008-11-01
5
283 Views
Last Modified: 2012-05-05
I have a series of tables

people
===============
id,strName,nOfficeID

office
==============
id,strName,nDistrictID

and then i have users

user
==============
id,strUsername

and then finally which districts the users can view

userdistrict
==============
id,nDistrictID,nUserID

I want to get a list of all people but only people that belong to offices which are in districts that I as a user can see. A user may see multiple districts.
0
Comment
Question by:phenixfilms
  • 2
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 22858847
you mean:
select p.strName, o.strName office_name
  from userdistrict ud
  join office o
    on o.nDistrictID = ud.nDistrictID
  join people p
    on p.nOfficeID = o.id
where id.nUserID = 1234  <<<-- the user you are querying for

Open in new window

0
 
LVL 1

Author Comment

by:phenixfilms
ID: 22858885
What about the user? I see your selecing WHERE id.nUserID.... but you've never set id to be a table or anything.

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22858920
that should have been ud.nUserID instead of id.nUserid ...
ud being the table alias of userdistrict.

I assume that you want to query for 1 single user...
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now