BINARY casts the string to a binary string : BINARY « Cast Functions Operators « MySQL Tutorial






BINARY causes the comparison to be case sensitive.

BINARY also causes trailing spaces to be significant.

BINARY str is shorthand for CAST(str AS BINARY).

mysql>
mysql> SELECT 'a' = 'A';
+-----------+
| 'a' = 'A' |
+-----------+
|         1 |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT BINARY 'a' = 'A';
+------------------+
| BINARY 'a' = 'A' |
+------------------+
|                0 |
+------------------+
1 row in set (0.00 sec)

mysql> SELECT 'a' = 'a ';
+------------+
| 'a' = 'a ' |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)

mysql> SELECT BINARY 'a' = 'a ';
+-------------------+
| BINARY 'a' = 'a ' |
+-------------------+
|                 0 |
+-------------------+
1 row in set (0.00 sec)

mysql>








17.2.BINARY
17.2.1.BINARY casts the string to a binary string