Maurice van der Stee
2018-11-29 12:52:48 UTC
Hello,
I have a sqlite database containing a table config with amongst others
the column conf_flags. I want to select entries from this table which
have one or more specific flags set.
If do
select config_flags from config where config_flags & WANTED_FLAG != 0.
I get the correct result. Now this works if there is only one flag to
test for. With multiple flags this works:
select config_flags from config where (config_flags & (WANTED_FLAG1 |
WANTED_FLAG2)) != 0
but this also returns the rows with only one of the flags set, which is
not what I want.
This returns 0 rows:
select config_flags from config where (config_flags &
WANTED_FLAG) = WANTED_FLAG.
The strange thing is that if I do
select config_flags, config_flags & WANTED_FLAG from config where
(config_flags & WANTED_FLAG) != 0.
This has the correct evaluation in the second result column.
So what am I doing wrong.
===============================
Maurice van der Stee (***@planet.nl)
I have a sqlite database containing a table config with amongst others
the column conf_flags. I want to select entries from this table which
have one or more specific flags set.
If do
select config_flags from config where config_flags & WANTED_FLAG != 0.
I get the correct result. Now this works if there is only one flag to
test for. With multiple flags this works:
select config_flags from config where (config_flags & (WANTED_FLAG1 |
WANTED_FLAG2)) != 0
but this also returns the rows with only one of the flags set, which is
not what I want.
This returns 0 rows:
select config_flags from config where (config_flags &
WANTED_FLAG) = WANTED_FLAG.
The strange thing is that if I do
select config_flags, config_flags & WANTED_FLAG from config where
(config_flags & WANTED_FLAG) != 0.
This has the correct evaluation in the second result column.
So what am I doing wrong.
===============================
Maurice van der Stee (***@planet.nl)