Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
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”;