Re: Can you filter SELECT results? Hi
It would be simpler if you dispensed with granting access to an individual
then it would be one query joining the menu, menugrpaccess and usr2grp
tables filtering on the userID in the usr2grp table, something like:
SELECT M.MenuId, M.Name
FROM Menu M
JOIN MenuGrpAccess A ON A.MenuId = M.MenuId
JOIN Usr2Grp G ON G.GroupId = A.GroupId
WHERE G.UserId = @UserId
This does assume that you do not have groups within groups (not another
hierarchy!!!!!) .
John
<wackyphill@yahoo.com> wrote in message
news:1103317871.779405.261970@z14g2000cwz.googlegr oups.com...
> Well, it goes back to my menu problem. You see I'd like to be able to
> say which menus show up for a particular person or group. Since this
> same menu info will be accessed by multiple programs it would be nice
> to have the logic for filtering out the menus on the DB rather than in
> each program.
>
> The way I determine if it is visible is like this (Maybe there is a
> better way)
>
> Given a userID I check the menuUserAccess table to see if there is a
> record macthing that UserID and the menuID in question. If so the user
> has access to it. What makes it more complex is the groups. If the 1st
> test failed I'd need to get an array of groupIDs the user belongs to
> from my usr2grp table. Finally I'd loop thru each of them and see if a
> record exists in the menuGrpAccess table containing that groupID and
> the menuID in question.
>
> The presence of the record means the group / user has access.
> Maybe this is a flawed design?
> |