0

For example 10 = 2+8 = 2^1 + 2^3

In the query, How can I select it when I want the code contains 2^1 or 2^3?

sqluser
  • 5,502
  • 7
  • 36
  • 50
  • Please show what you have tried and we can take a look. – Bob Apr 01 '15 at 01:15
  • I couldn't help it... I wanted to know too so I looked it up. Try using the bitwise and. If you take the field and use a bitwise and with the number you are looking for, and the result equals the number you are looking for, then the bit is on. – Bob Apr 01 '15 at 01:31

1 Answers1

0

You can try:

where (10 & (1 << 1) ) > 0 or  (10 & (1 << 3)) > 0

Or, as a single operator:

where 10 & ( (1 << 1) | (1 << 3) ) > 0
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786