I have been working on some reports and recently found a small guide for the system I have been querying against. Part of the syntax it offers up is like the following:
... "WHERE [FIELD] & [VALUE] = [VALUE]"
i.e.: ... "WHERE flags & 16 = 16"
I am just curious as to what this syntax is meaning... I get something like WHERE flags = 16, but not the '&16 = 16' part. Any clarification?
The article referenced: http://rightfaxapi.com/advanced-sql-for-manipulating-faxes/
Thank you, Wes
The
&
is doing a bit-wise "and". So, it is "1" only when both bits are 1. The logic overall is checking that all the bits invalue
are set infield
.As an example, consider that
value
is:Then if field is
The
&
is:(The
1
s are only where both are1
.)And this is the same as
value
. So, this passes the condition.Now if
field
is:Then the
&
is:And this differs from
value
, so it does not pass the condition.