Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Difference Between 2 Queries
kvarnerexpress
post Dec 25 2005, 01:38 AM
Post #1


Super Member
*********

Group: Members
Posts: 407
Joined: 13-December 04
Member No.: 2,696



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,
Go to the top of the page
 
+Quote Post
kvkv
post Jan 30 2006, 05:51 PM
Post #2


Newbie [Level 3]
***

Group: Members
Posts: 40
Joined: 29-January 06
Member No.: 17,841



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Difference Between C, C++ And C#?(12)
  2. Advertised Isp Speed Versus Actual Speed(5)
  3. What's The Difference Between 64 And 32 Bit?(9)
  4. Difference Between Love And Crush(12)
  5. What Is The Main Difference Between Religions?(10)
  6. Java Helpdesk(8)
  7. Social Vibe, Join & Make A Difference!(0)
  8. What Is The Difference Between Addon Domain & Parked Domain?(1)
  9. Save The World... One Click At A Time!(6)
  10. Php Time Difference(5)
  11. What Is The Difference Between Asp And Php?(3)
  12. Molecule Vs Lattice(2)
  13. School And Knowledge: Whats Da Difference(0)
  14. What Is The Difference Between Jdk 6 And J2sdk ?(1)
  15. Tos Queries(2)
  1. Difference Between Men And Women.. Funny Pic. Lol(3)
  2. Vietnam/iraq(10)
  3. Mysql And Sql(7)
  4. Difference Between College And University(15)
  5. Attraction: The Difference Between The Sexes(8)
  6. Photoshop Cs2 & Photoshop Cs3(4)
  7. Ubuntu Or Kubuntu(8)
  8. Php Version Difference Error(1)
  9. Difference Between Canadians And Americans(9)
  10. What Is The Difference...?(6)
  11. The Difference Between Mysql And Postgresql ?(4)
  12. What's The Difference - Sub-domain With Parked Domain Name And Just Domain Name?(5)
  13. Difference Between The 2005 Ps3 And The New 2006 Ps3(5)
  14. Too Many Mysql Queries?(1)
  15. The Difference Between Cms And Portal?(0)


 



- Lo-Fi Version Time is now: 20th July 2008 - 05:36 PM