Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

BINARY

Example

Convert a value into its binary string representation.

SELECT BINARY “W3Schools.com”;

Definition and Usage

The BINARY function converts a value to a binary string. 

Note: This function performs the same operation as using CAST(value AS BINARY).

Syntax

BINARY value

Parameter Values

Parameter

Description

number

Required: The value that will be converted.

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

In MySQL, a character-by-character comparison of “HELLO” and “hello” would return 1 because, at a basic comparison level, they are considered equivalent.

SELECT “HELLO” = “hello”;

Example

In MySQL, a byte-by-byte comparison of “HELLO” and “hello” would return 0 because, at the byte level, they are not considered equivalent.

SELECT BINARY “HELLO” = “hello”;