SQL Puzzle – A Quick Fun with Bit Wise Operator – Part 2

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.

SQL Puzzle - A Quick Fun with Bit Wise Operator - Part 2 bitwiseor1

Now execute following query:

SELECT 10 | 0

The above query will return us result as a 10 as well.

SQL Puzzle - A Quick Fun with Bit Wise Operator - Part 2 bitwiseor2

Now let us execute following query:

SELECT 1 | 100

It will return us result as a 101.

SQL Puzzle - A Quick Fun with Bit Wise Operator - Part 2 bitwiseor3

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)

SQL Scripts
Previous Post
SQL Puzzle – A Quick Fun with Bit Wise Operator
Next Post
Developers – A Fun List of Things Related to Developer

Related Posts

Leave a Reply