How do I remove all spaces from a field in a Postgres database in an update query?

前端 未结 7 1675
梦毁少年i
梦毁少年i 2020-12-30 18:58

What would be the proper syntax used to run an update query on a table to remove all spaces from the values in a column?

My table is called users and in

7条回答
  •  滥情空心
    2020-12-30 19:40

    UPDATE customers SET first_name = TRIM (TRAILING FROM first_name ) where id = 1
    

    For example, if you want to remove spaces from the beginning of a string, you use the following syntax:

    TRIM(LEADING FROM string) The following syntax of the TRIM() function removes all spaces from the end of a string.

    TRIM(TRAILING FROM string) And to remove all spaces at the beginning and ending of a string, you use the following syntax:

    TRIM(BOTH FROM string)

提交回复
热议问题