Bitwise Operators
- Bitwise Operators are:
Bitwise operators | Description |
---|---|
& | Bitwise AND |
| | Bitwise OR |
^ | Bitwise exclusive OR |
<< | Left Shift |
>> | Right Shift |
Syntax:
SELECT (col1 & num1), (col2 | num2), ….. FROM tableName;
Example:
Create student table:
ID | Name | Physics | Chemistry |
---|---|---|---|
1 | Aman | 86 | 92 |
2 | Sushant | 91 | 91 |
3 | Saumya | 98 | 98 |
Bitwise AND operations:
SELECT Physics & Chemistry FROM student;
Bitwise OR Operation:
SELECT Physics | Chemistry FROM student;