Searching for a 'binary mask' in MySQL

I have a field in mysql that is stored as a binary value.  This field represents multiple roles a person can have and the 'stacking' of those roles.

Example;
admin - 00000001
user   - 00000010
mod      00000100

Someone that is an admin & moderator would be 00000101.

Given this query, only someone with an admin role is returned:
Select first_name, last_name
From users
where role  = '00000001';

Is it possible?
LVL 1
mynamebecory2Asked:
Who is Participating?
 
theGhost_k8Database ConsultantCommented:
0
 
spoxoxCommented:
Not sure what your goal is.
If you want to discover all with administrator rights, even if they have other rights as well, you can use

WHERE ROLE LIKE '_______1'

Character      Description
%               Matches any number of characters, even zero characters
_               Matches exactly one character

http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
0
 
spoxoxCommented:
Last post assumes the ROLE column is a string - is it a number?
0
 
mynamebecory2Author Commented:
100 high fives to you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.