MySQL | BINARY Function
Last Updated :
21 Nov, 2019
Improve
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 valueParameters Used:
- value - It is used to specify the value to be converted.
- MySQL 5.7
- MySQL 5.6
- MySQL 5.5
- MySQL 5.1
- MySQL 5.0
- MySQL 4.1
- MySQL 4.0
- MySQL 3.23
SELECT BINARY('Geeksforgeeks');Output:
GeeksforgeeksExample-2: Character-by-character comparison of two string without using BINARY function.
SELECT 'GEEKSFORGEEKS' = 'geeksforgeeks';Output:
1Example-3: Byte-by-Byte comparison of two string using BINARY function.
SELECT BINARY 'GEEKSFORGEEKS' = 'geeksforgeeks';Output:
0Example-4: Byte-by-Byte comparison of two string using BINARY function.
SELECT BINARY 'GEEKSFORGEEKS' = 'GEEKSFORGEEKS';Output:
1