If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Sql Query Help!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-09-06, 11:50
sub_woofer sub_woofer is offline
Registered User
 
Join Date: May 2005
Posts: 25
Sql Query Help!

Hey all,

Am struggling to write a query that returns the correct result!

I have 2 tables:

A user table (parent) and a permissions table (child).

- The user table consists of a list of all users of my system
- The permissions table consists of a list of activities that a user/user type may perform
-userid in the premissions table may be left blank as we could set permissions for a specific activity by user type

My question is : How do we retrieve which users do not have permissions for a particular activity???

I have tried many ways - but no luck so far. Some of my methods:

1) Select userid from users left join permissions on users.userid=permissions.userid where activity<>1 or userid is null

2) Then using subqueries to select all userid which did not exist in the subquery - no luck either!!!

Any help/hints/advice will be GREATLY appreciated!

sub
Reply With Quote
  #2 (permalink)  
Old 10-09-06, 17:17
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool


One way could be:

Code:
Select Userid From Users 
Where NOT EXISTS (
Select NULL From Permissions 
 Where Permissions.Userid = Users.Userid
   And Activity = <insert here the activity#> );


__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Last edited by LKBrwn_DBA; 10-09-06 at 17:22.
Reply With Quote
  #3 (permalink)  
Old 10-10-06, 04:35
sub_woofer sub_woofer is offline
Registered User
 
Join Date: May 2005
Posts: 25
Thanks alot LKBrwn_DBA...works PERFECTLY!

Reply With Quote
  #4 (permalink)  
Old 10-10-06, 15:19
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool


Glad it worked for you! -- Good luck.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On