MySQL BIN() Function Last Updated : 10 Jun, 2024 Comments Improve Suggest changes Like Article Like Report The BIN() function in MySQL converts a decimal number to its binary equivalent. The BIN() function is equivalent to the CONV() function written in the format CONV(number,10,2). In this format, the CONV() function converts the number 'number' from base 10 (decimal) to base 2 (binary). It is important to note that the BIN() function can only be used with positive integers. If you try to use a negative number or a non-integer value as the input to the BIN() function, MySQL will return an error. The BIN() function returns a string value, the binary equivalent of the decimal number passed as argument. It returns NULL if the number is NULL. SyntaxMySQL BIN() function Syntax is: BIN (decimal_number) Here, decimal_number is the decimal number you want to convert to binary. MySQL BIN() Function ExamplesLet's look at some examples of the BIN() function in MySQL. The example shows the SQL query for using BIN function in MySQL. Query: SELECT BIN(5); Output: '101'Query: SELECT BIN(12)Output: '1100' Comment More infoAdvertise with us Next Article MySQL BIN() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc SQL Databases Functions mysql +1 More Practice Tags : FunctionsMisc Similar Reads MySQL | BINARY Function The MySQL BINARY function is used for converting a value to a binary string. The BINARY function can also be implemented using CAST function as CAST(value AS BINARY). The BINARY function accepts one parameter which is the value to be converted and returns a binary string. Syntax: BINARY value Parame 1 min read MySQL | CONV( ) Function The MySQL CONV() function is used for converting a number from one numeric base system to another. The value returned by the CONV() function is in the form of a string value. It accepts three parameters which are the value to be converted, the current numeric base system and the numeric base system 2 min read PLSQL | BITAND Function The BITAND is an inbuilt function in PLSQL which is used to returns an integer value which is calculated with AND operation of two given input decimal number. Internally these input decimal numbers get converted into binary numbers and then AND operation is performed and results are returned as outp 2 min read BIT_OR() Function in MySQL BIT_OR() function in MySQL is used to return the bitwise OR of all bits in a given expression. It first converts all decimal values into binary values, and then perform bitwise or operation on those binary values. Syntax : BIT_OR(expr) Parameter : This method accepts only one parameter. expr - Input 4 min read MySQL | CAST( ) Function The MySQL CAST() function is used for converting a value from one datatype to another specific datatype. The CAST() function accepts two parameters which are the value to be converted and the datatype to which the value needs to be converted. The datatypes in which a given value can be converted are 3 min read Like