Bin Function In Sql in SQL
? BIN() Function in SQL
The BIN() function converts an integer number to its binary (base-2) string representation.
? Syntax
BIN(number)number: An integer value.Returns a string representing the binary form of the number.
? Examples
1. Convert 5 to binary
SELECT BIN(5);-- Returns '101'2. Convert 10 to binary
SELECT BIN(10);-- Returns '1010'3. Convert 0 to binary
SELECT BIN(0);-- Returns '0'?? Notes
Available in MySQL and some other SQL dialects (but not all).
Input should be an integer.
Returns the binary string without any prefix (
0b).
Let me know if you want examples converting binary back to decimal or using bitwise operators in SQL!