Select Statement with Temp Column driven by Bitmask
1
vote
1
answer
310
views
I have a role system setup that checks to see if bits are set for specific roles.
Each user has a specific assigned that is stored in our database and gives them access to different parts of the program. What I'm trying to do is pull every user from the database and add a column beside the role number with what parts they have access to.
I can do this with a case statement but that will only find one of the permissions unless I break down all the combinations of cases.
------------------
Database Setup:
Name | Role |
Jon | 77 |
---------------
Permissions:
@ONE = 1
@TWO = 2
@THREE = 4
@FOUR = 8
@FIVE = 16
@SIX = 32
@SEVEN = 64
@EIGHT = 128
@NINE = 256
@TEN = 1024
@ELEVEN = 2048
@TWELVE = 32768
@THIRTEEN = 65471
-----------------
So for Jon I want to see:
Name | Role | Roles
Jon | 77 | One Three Four Seven
Asked by Zach Buechler
(13 rep)
Dec 19, 2016, 06:52 PM
Last activity: Jan 6, 2017, 03:40 PM
Last activity: Jan 6, 2017, 03:40 PM