MySQL tutorial: BINARY OPERATOR [EN]
top of page
CerebroSQL

MySQL: 

BINARY OPERATOR

Syntax:
BINARY expr

The BINARY operator converts the expression to a binary string (a
string that has the binary character set and binary collation). A
common use for BINARY is to force a character string comparison to be
done byte by byte using numeric byte values rather than character by
character. The BINARY operator also causes trailing spaces in
comparisons to be significant. For information about the differences
between the binary collation of the binary character set and the _bin
collations of nonbinary character sets, see
https://dev.mysql.com/doc/refman/8.0/en/charset-binary-collations.html.

URL: https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html

Example

mysql> SELECT 'a' = 'A';
-> 1
mysql> SELECT BINARY 'a' = 'A';
-> 0
mysql> SELECT 'a' = 'a ';
-> 1
mysql> SELECT BINARY 'a' = 'a ';
-> 0

bottom of page