Search code examples
mysqlsqlsql-updatetrimstring-function

MySQL: UPDATE column WHERE column STARTS WITH " " (Blankspace)


I need to search and UPDATE my database for column values starting with a blankspace..

SQL

UPDATE table
  SET column substring(column, 1)
  WHERE column has blankspace

How can i do this?

EDIT
Oh yeah.
Reason is to erase blankspace...


Solution

  • Use LTRIM() function to remove starting blank spaces.

    Try this:

    UPDATE table SET column = LTRIM(column)