Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Difference Between 2 Queries

Recommended Posts

I'm working on a piece of user/group authentication and I've run into a question that has to do with ASP coding, I think. I have very little experience with ASP, though.In essence, I have a couple of tables: users, groups, articles, Permissions for articles, and Groupmemberships... So, on a page, it opens up the article and looks for what groups have been given access to the article... It then looks at the userID (session variable) and determines what groups the user belongs to.... you I'll have 2 lists, the groups the user is in and the the groups that have access to the article... If there is any common between the two, then the user has access... otherwise they don't.So...User Group IDs^^^^^^^^^^^Article Group IDs1^^^^^^^^^^^^^^^^^^^33^^^^^^^^^^^^^^^^^^^47^^^^^^^^^^^^^^^^^^^2This person would have permission because the user belongs to one or more groups that have permission...or...User Group IDs^^^^^^^^^^^Article Group IDs1^^^^^^^^^^^^^^^^^^^83^^^^^^^^^^^^^^^^^^^47^^^^^^^^^^^^^^^^^^^2This person would get an access denied error.... So, my question is, how would I compare the two to see if there are any common elements in ASP or SQL? The data is in a MS SQL database...Thanks,

Share this post


Link to post
Share on other sites

You have provided both the tables the same. I am assuming this is your table structure


-----------------------------
User-group
-----------------------------
user-id, group-id


-----------------------------
group-articles
-----------------------------
group-id, article-id


You can use sql to check the permissions

select * from user-group, group-articleswhere user-group.group-id=group-articles.group-idanduser-id=<user id>andarticle-id=<article id>

replace <> with actual values. If this query returns results, then the user has permission. Otherwise, he doesn't. Note that it requires only one query.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.