1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What are the differences between non-binary strings and binary strings ?

Discussion in 'MySQL' started by karumi, Mar 4, 2010.

  1. #1
    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 ? :(
    SEMrush
     
    karumi, Mar 4, 2010 IP
    SEMrush
  2. jimmy4feb

    jimmy4feb Peon

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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
     
    jimmy4feb, Mar 4, 2010 IP
  3. HydrogenBots

    HydrogenBots Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    HydrogenBots, Mar 4, 2010 IP
  4. karumi

    karumi Peon

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    @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 ?
     
    karumi, Mar 5, 2010 IP
  5. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #5
    Hi,

    Please check this url
    Regards :)
     
    koko5, Mar 5, 2010 IP
  6. karumi

    karumi Peon

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank all of you. I understand it :)
     
    karumi, Mar 5, 2010 IP