I have a table that store access privileges as a bitwise mask:
0
none1
user2
super-user
I want to query, for instance, all accounts that have user
+ super-user
priviledges, I thought that:
SELECT * FROM "accounts" WHERE "privileges" & 3;
Would work, but it's also returning all normal user (1
) accounts. I can see that this it's correct because:
1 (01)
& 3 (11)
-----------
= 1 (01)
I remember that this was easily doable in MySQL for instance, but I forgot how in the meantime.
I think the solution is probably a simple one, can anyone give me a hint on this?