skip to Main Content

I have thousands of entries in a wordpress site with a custom field called description and inside all of them, I have a leading white space, like this:

" bla, bla, bla"

And I need to remove all that white spaces like this:

"bla, bla, bla"

I was trying to do this $sql = "UPDATE $wpdb->postmeta set description = ltrim(rtrim(description))"; but is not working.

phpmyadmin says: # 1054 - Unknown 'description' column in 'field list'

Is it possible, and or how?

2

Answers


  1. you can use the TRIM function of MySQL (See reference)

    UPDATE $wpdb->postmeta set description = TRIM(description);
    
    Login or Signup to reply.
  2. UPDATE
        $wpdb->postmeta
    SET 
        description = RTRIM(description);
    

    Try to write trim in Capital

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search