MySQL BINARY Function

MySQL Functions : Convert a value to a binary string

Definition and Usage

The BINARY function converts a value to a binary string.

This function is equivalent to using CAST(value AS BINARY).

Syntax

BINARY value

Parameter Values

Parameter Description
value Required. The value to convert

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Here MySQL performs a character-by-character comparison of  "HELLO" and "hello" and return 1 (because on a character-by-character basis, they are equivalent):

SELECT "HELLO" = "hello";

Example

Here MySQL performs a byte-by-byte comparison of  "HELLO" and "hello" and return 0 (because on a byte-by-byte basis, they are NOT equivalent):

SELECT BINARY "HELLO" = "hello";