Hi,
I use in an SQL table an Integer column called 'Caps' to store capabilities. Each bit of the integer represent a capability. Now I need to select in an SQL statement only those rows that have a specific capability. And i cant find how to do this! Someone knows?
Assume
-row 1 of the table has Caps 4
-row 2 of the table has Caps 5
-row 3 of the table has Caps 3
This is what i tried and did NOT work (assume I look for the 3rd bit, I only want rows 1 and 2):
SELECT * FROM table WHERE Caps AND 0x4 = 0x4
or
SELECT * FROM table WHERE Caps & 0x4 = 0x4
or
SELECT * FROM table WHERE oct(Caps) & 0x4 = 0x4
Anyone has a suggestion?
I use in an SQL table an Integer column called 'Caps' to store capabilities. Each bit of the integer represent a capability. Now I need to select in an SQL statement only those rows that have a specific capability. And i cant find how to do this! Someone knows?
Assume
-row 1 of the table has Caps 4
-row 2 of the table has Caps 5
-row 3 of the table has Caps 3
This is what i tried and did NOT work (assume I look for the 3rd bit, I only want rows 1 and 2):
SELECT * FROM table WHERE Caps AND 0x4 = 0x4
or
SELECT * FROM table WHERE Caps & 0x4 = 0x4
or
SELECT * FROM table WHERE oct(Caps) & 0x4 = 0x4
Anyone has a suggestion?