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.

I can't delete double blank

Discussion in 'MySQL' started by piropeator, Jun 11, 2016.

  1. #1
    My MySQL table has a nom fied varchar(60) utf-general-ci
    and there are rows like this:
    nom = " ANA MARIA"
    I run this:
    UPDATE table SET nom = Replace(nom, '  ', ' ') 
    PHP:
    But nothing.
    SEMrush
     
    piropeator, Jun 11, 2016 IP
    SEMrush
  2. mmerlinn

    mmerlinn Notable Member

    Messages:
    1,612
    Likes Received:
    174
    Best Answers:
    5
    Trophy Points:
    240
    #2
    Of course it won't work. Your variable nom has ONE space, three letters, ONE space, and five letters. You can't delete single spaces separated by other printable characters using double spaces in your code. Just use single spaces in your code, and the single spaces will disappear leaving you with what you want 'ANAMARIA'
     
    mmerlinn, Jun 11, 2016 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,626
    Likes Received:
    719
    Best Answers:
    151
    Trophy Points:
    420
    #3
    Or just use trim() around the variable, preferably before you put it into your database. Don't try to fix data already in the database, that's a waste of time and resources, fix it preferably before you put the data in, or fix it when it's displayed.
     
    PoPSiCLe, Jun 11, 2016 IP
    sarahk likes this.