Search Postgresql Archives

Re: trimming a column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/03/2012 06:55 PM, Greg Williamson wrote:
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).

Actually not:)
test=> SELECT  length(trim(' test '));
 length
--------
      4


(untested)

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

HTH,

Greg Williamson



--
Adrian Klaver
adrian.klaver@xxxxxxxxx

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux