Re: trimming a column

From: Greg Williamson <gwilliamson39(at)yahoo(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: trimming a column
Date: 2012-05-04 01:55:02
Message-ID: 1336096502.92579.YahooMailNeo@web46110.mail.sp1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Michael --

>Hi,
>
>I need to trim whitespace off of a whole column and replace the existing
>values with the trimmed ones.
>
>This isn't working
>
>update mytable set id = trim(id);
>
>I'm not sure of the correct syntax. Help appreciated.
>
>Mike
>

The trim function needs to be told what sort of trim to do --

Following the 9.1 manual (you did not specify which version of postgres you are using) try:

  UPDATE mytable SET id = trim(both ' ' from id).

(untested)

See <http://www.postgresql.org/docs/9.1/static/functions-string.html>

HTH,

Greg Williamson

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-05-04 02:05:12 Re: trimming a column
Previous Message Michael P. Soulier 2012-05-04 01:01:42 trimming a column