Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not Sure How To Code This Query
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01397296
Message ID:
01397398
Views:
57
Kevin,

Sorry, I think I will give up for now.


>Yes.
>
>Let me explain a bit more. Consider the following tables:
>
>
>TABLE: Users
>UserId      RoleId      FullName
>----------- ----------- -------------------
>37          31          Gerald Ford
>38          32          George Washingtion
>39          32          William Cinton
>40          33          Thomas Jefferson
>41          33          John Kennedy
>42          33          Ronald Reagan
>
>
>TABLE: Roles
>RoleId      RoleName      
>----------- ------------- 
>31          Administrtor  
>32          Shipping      
>33          Receiving     
>
>
>TABLE: Rights
>RightId     RightName                   RightCode            Access
>----------- ------------------------------------------------ ------
>10          Login                       login                1
>11          View Ship Items             vw_shipitems         1
>12          View Shipping Inventory     vw_shipinv           1
>13          View Shipping Reports       vw_shiprpts          1
>14          View Receive Items          vw_rcvitems          1
>15          View Transfer Items         vw_xferitems         1
>16          View Relocate Items         vw_rlocitems         1
>17          View Receiving Inventory    vw_rcvinv            1
>18          View Receiving Reports      vw_rcvrpts           1
>
>
>TABLE: RoleRights
>RoleRightId RoleId      RightId   Access
>----------- ----------- --------- ------
>16          32          10        1
>17          32          11        1
>18          32          12        1
>19          32          13        1
>20          33          10        1
>21          33          14        0
>22          33          15        1
>23          33          16        0
>24          33          17        1
>25          33          18        1
>
>
>TABLE: UserRights
>UserRightId UserId      RightId   Access
>----------- ----------- --------- ------
>1           37          15        0
>
>
>
>If user Thomas Jefferson logs in, his role his RoleId is 33, or "Receiving", so the query should return all rights that are defined in RoleRights with a RoleId of 33. Then, after that, overlay any record in that set with the UserRight record with the same RightId and UserId
>
>Therefore, the result set should look like this:
>
>
>TABLE: RoleRights
>RoleRightId RoleId      RightId   Access
>----------- ----------- --------- ------
>16          32          10        1
>17          32          11        1
>18          32          12        1
>19          32          13        1
>20          33          10        1
>21          33          14        0
>1            33          15        0      <<--- This row was obtained from UserRights
>23          33          16        0
>24          33          17        1
>25          33          18        1
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform