BINARY
The BINARY
operator casts the string following it to a binary string. This is an easy way to force a column comparison to be done byte by byte rather than character by character. This causes the comparison to be case sensitive even if the column isn't defined as BINARY
or BLOB
.
BINARY
also causes trailing spaces to be significant.
SELECT 'a' = 'A'; +-----------+ | 'a' = 'A' | +-----------+ | 1 | +-----------+ SELECT BINARY 'a' = 'A'; +------------------+ | BINARY 'a' = 'A' | +------------------+ | 0 | +------------------+ SELECT 'a' = 'a '; +------------+ | 'a' = 'a ' | +------------+ | 1 | +------------+ SELECT BINARY 'a' = 'a '; +-------------------+ | BINARY 'a' = 'a ' | +-------------------+ | 0 | +-------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/binary-operator/