select n,n and 3,n & 3, n mod 4, n and false,n and true
from (select 0 n union select 1 union select 2 union
select 3 union select 4 union select 5 union
select 6 union select 7 union select null) v1;
Hints:
The subquery v1 returns column n with the rows 0,1,2,3,4,5,6,7,null.
“&” is the binary and-operation. “MOD” is the modulo (remainder) calculation.
Mysql treats 0 as false and anything else as true.
The constants TRUE and FALSE have the values 1 and 0.
And, did you get it right?
“3″ is a true value, that makes “n and true” and “n and 3″ the same. The modulo and bit-operations are obvious and so is the fact, that an operation with NULL results in NULL.
For me the most interesting part is, that TRUE AND NULL is NULL, where as FALSE AND NULL is FALSE.