May 16, 2008

Difference Between 2 Queries

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > .NET ( ASP.net VB.net )

free web hosting

Difference Between 2 Queries

kvarnerexpress
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 IDs
1^^^^^^^^^^^^^^^^^^^3
3^^^^^^^^^^^^^^^^^^^4
7^^^^^^^^^^^^^^^^^^^2

This person would have permission because the user belongs to one or more groups that have permission...
or...

User Group IDs^^^^^^^^^^^Article Group IDs
1^^^^^^^^^^^^^^^^^^^8
3^^^^^^^^^^^^^^^^^^^4
7^^^^^^^^^^^^^^^^^^^2

This 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,

 

 

 


Reply

kvkv
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
CODE

select *
from user-group, group-articles
where user-group.group-id=group-articles.group-id
and
user-id=<user id>
and
article-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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : difference queries


    Looking for difference, 2, queries

Searching Video's for difference, 2, queries
advertisement



Difference Between 2 Queries



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE