This is a follow up, puzzle of SQL Puzzle – A Quick Fun with BitWise Operator. Lots of people really like the earlier puzzle where I have used Bit Wise Operator AND and build a simple puzzle. Today we are going to use another bit wise operator – OR.
First execute following query:
SELECT 10 | 10
It will return us result as a 10.
Now execute following query:
SELECT 10 | 0
The above query will return us result as a 10 as well.
Now let us execute following query:
SELECT 1 | 100
It will return us result as a 101.
Here is the question back to you – Why does the last query return us result as a 101 when we have used Bit Wise Operator OR?
Reference: Pinal Dave (https://blog.sqlauthority.com)