Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL BIN Function

by suresh

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 BIN Function in MySQL 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 string BIN function, We are going to use the customerdetails table data that we showed below

MySQL String BIN Function Example

MySQL BIN Example 1

The String BIN in MySQL returns the Binary Values of the given numeric expression. The following BIN 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');

OUTPUT

MySQL BIN Function Example 1

String BIN Function Example 2

In this String Function example, we are going to implement the MySQL string BIN on different columns in a table. The following MySQL statement returns the Binary values of the data present in Yearly_Income and Sales Columns.

-- MySQL String BIN Example
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;

OUTPUT

MySQL BIN Function Example 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy