Inside MSACCESS I want to use relatively simple bitwise operations in WHERE clause of queries such as this:
SELECT *
FROM Table1
WHERE Column1 (some operator) 8 = 0
This would:
- Return rows where
Column1does not have its 4th bit set e.g. 0, 1, 2, …, 7 (all have their 4th bit clear) and 16 (it is 00010000b) - Exclude rows where
Column1is 8, 9, 10, …, 15 etc.
PS: are bitwise operators different from boolean operations?
If you can run your query in in ANSI-92 Query Mode (e.g. by changing the Access UI Query Mode or by connecting to it using ADO classic or ADO.NET), use the
BANDoperator.The following code sample prints this to the Immediate window:
The first case (AND) treats both numbers as True values, so
True AND Truegives -1 (True). I think the BAND approach is what you’re after.