Hi everyone. I am newbie at MySQL databases. I studied my first lesson yesterday about MySQL data types and I really do not understand about the definition of "non binary string" and "binary string". May anyone help me ?
Hello, When we need to compare two string using MySql queries, then by default MySql does not care about the case-sensitivity(case-sensitivity means: the string is a capital letter or in small letters) of the strings. So If we want MySql to take care of this case-sensitivity we use "BINARY" keyword in MySql query. Lets understand it with simple example: this query will not take care of case-sensitivity: SELECT 'abc' = 'ABC'; SELECT 'abc' = "AbC"; When you will run the above queries in MySql, then the results will come 1 (for true values, MySql returns 1) Now on other hand if we use BINARY keyword then MySql will take care of case-sensitivity: SELECT BINARY 'acb' = 'ABC'; SELECT BINARY 'aBc' = 'ABC'; When you will run- above queries in MySql, then the results will come 0 (for false values, MySql returns 0) I think is the answer of your question. If you still have any question, then feel free to ask. Thanks, Jimmy
for most applications you should stick with non-binary unless you have an absolute need it, I'll put it this way, in over 5 years using php and mysql I've never found a need for it. In the excellent examples jimmy stated, this shows the most basic usage of it.
@jimmy4feb and HydrogenBots: Thank for your help but when we use non-binary string and binary string in declaration ? Do binary string use only for string comparision ?