dbTalk Databases Forums  

SQL Query Problem

comp.databases comp.databases


Discuss SQL Query Problem in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
George Hernando
 
Posts: n/a

Default SQL Query Problem - 02-21-2004 , 11:17 AM






Please help me with the following problem.

I have an item table with a Access Control List (ACL)
Column 1 -- Item ID
Column 2 -- ACL ID

In the ACL definition table, there are privileges:
Column 1 -- ACL ID
Column 2 -- Privilege ID
For a given ACL ID there is a list of allowed privileges.

I want to do a search that returns a result set that has
at most one row for an item and an indicator if the item
as one of a sepcified privilege.

Ex: Find the items based on some citeria and also find
if the item has Priv5, Priv8 and Priv20

I would like the result set to look like:

Item ID, Priv5 Indicator, Priv 8 Indicator, Priv 10 Indicator

I guess the Indicator could be 0 or 1. 0 if no privilege,
1 if the privilege is assigned to that item.

I don't want to have to post process the query looping through
the result set to check the privileges.

Thanks for any help!!

Reply With Quote
  #2  
Old   
Bob Badour
 
Posts: n/a

Default Re: SQL Query Problem - 02-21-2004 , 01:13 PM






"George Hernando" <georgehernando (AT) hotmail (DOT) com> wrote

Quote:
Please help me with the following problem.

I have an item table with a Access Control List (ACL)
Column 1 -- Item ID
Column 2 -- ACL ID

In the ACL definition table, there are privileges:
Column 1 -- ACL ID
Column 2 -- Privilege ID
For a given ACL ID there is a list of allowed privileges.

I want to do a search that returns a result set that has
at most one row for an item and an indicator if the item
as one of a sepcified privilege.

Ex: Find the items based on some citeria and also find
if the item has Priv5, Priv8 and Priv20

I would like the result set to look like:

Item ID, Priv5 Indicator, Priv 8 Indicator, Priv 10 Indicator

I guess the Indicator could be 0 or 1. 0 if no privilege,
1 if the privilege is assigned to that item.

I don't want to have to post process the query looping through
the result set to check the privileges.

Thanks for any help!!
CASE/WHEN + GROUP BY + MAX (or MIN or SUM or COUNT)




Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.