Hello,
I have put a number of options into one binary number.
Now I am looking for a query that selects rows that have one option, Not have another option while a third option is irrelevant.
For instance:
If a bicycle has handbrakes, I OR the options with 4
If it has a rear light I or it with 2
And if it has a headlight I or it with 1
How do I select all bikes that:
Have a rear light, NOT have handbrakes and I do not care wether they have a headlight or not?
Would that go something like this?
$andmask=1 OR 4
$resultmask=1
SELECT * FROM `bikes` WHERE `options` AND $andmask = $resultmask
I have put a number of options into one binary number.
Now I am looking for a query that selects rows that have one option, Not have another option while a third option is irrelevant.
For instance:
If a bicycle has handbrakes, I OR the options with 4
If it has a rear light I or it with 2
And if it has a headlight I or it with 1
How do I select all bikes that:
Have a rear light, NOT have handbrakes and I do not care wether they have a headlight or not?
Would that go something like this?
$andmask=1 OR 4
$resultmask=1
SELECT * FROM `bikes` WHERE `options` AND $andmask = $resultmask