[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
BINARY
BINARY
operator casts the string following it to a binary string.
This is an easy way to force a column comparison to be case sensitive even
if the column isn't defined as BINARY
or BLOB
:
mysql> SELECT "a" = "A"; -> 1 mysql> SELECT BINARY "a" = "A"; -> 0 |
BINARY string
is a shorthand for CAST(string AS BINARY)
.
See section 12.5 Cast Functions.
BINARY
was introduced in MySQL Version 3.23.0.
Note that in some context MySQL will not be able to use the
index efficiently when you cast an indexed column to BINARY
.
If you want to compare a BLOB
case-insensitively you can always convert
it to uppercase before doing the comparison:
SELECT 'A' LIKE UPPER(blob_col) FROM table_name; |
We plan to soon introduce casting between different character sets to make string comparison even more flexible.