MySQL BIN function is one of the String Functions, which is to return the string representation of the binary value of a number. The basic syntax of the MySQL BIN Function is as shown below:
SELECT BIN(Numeric_Expression) FROM [Source]
Numeric_Expression: Please specify a valid Expression or Number. It accepts up to BIG INT. To demonstrate this, We are going to use the customerdetails table data that we showed below
MySQL BIN Example
The String BIN returns the Binary Values of the given numeric expression. The following query shows multiple ways to use this function.
SELECT BIN(12); SELECT BIN(4029); -- Let me use NULL value as input SELECT BIN(NULL); -- It Omits the decimal values SELECT BIN(12.56); SELECT BIN('A');
USE company; SELECT First_Name, Last_Name, Education, Profession, Yearly_Income, BIN(Yearly_Income) AS Binary_Income, Sales, BIN(Sales) AS Binary_Sales FROM customerdetails;