![]() The BINARY operator is deprecated as of MySQL 8.0.27, and you should expect its removal in a future version of MySQL. ![]() ![]() For example, in this queryīINARY is used with brackets like a function. You can treat the use of BINARY operator as a function like BINARY().Returns 0 which is FALSE because the string on the right-hand side of the equal sign has a trailing space. The BINARY operator also causes trailing spaces in comparisons to be significant.Note that category 'Seafood' is not in the result because the first letter 'S' is uppercase.īelow is the case-insensitive version of the above query and it extracts all category records where the category name contains character 's' or 'S' (both lowercase 's' and uppercase 'S' are returned in the result).Ī couple of things to note about using BINARY operator: It extracts all category records where the category name contains lowercase character 's'. The following query is case-sensitive search against a column by using BINARY operator. Query above returns 1 which is TRUE, whereas select 'géek' = BINARY 'geek' returns 0 which is FALSE. It forces a character string comparison to be done byte by byte using numeric byte values rather than character by character.įor example, the following query returns 1 which stands for TRUE because the string geek is the same as string GEEK.īut if we apply BINARY operator to the string 'GEEK', the result is FALSE (returns 0) because the string lowercase geek is different to uppercase string GEEK. The BINARY operator converts a character string to a binary string. String comparison is NOT case-sensitive by default in MySQL, but if there is a need for case-sensitive string comparison, there are ways to deal with it. ![]() How to make case-sensitive comparison in MySQL ![]()
0 Comments
Leave a Reply. |