2

What does & indicate in below query? What is the meaning of it?

select id, name 
from test 
where num & 1 = 1; 

1 Answer 1

6

It's a bitwise and operator.

See the documentation here.

Wikipedia goes into lots of detail on bitwise operations.

Logically, the query you give:

select id, name 
from test 
where num & 1 = 1; 

... will only return odd numbers, due to the lower bit in any integer always being 1 when a number is odd.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.