On Wed, Dec 23, 2009 at 4:08 PM, jose isaias cabrera <cabr...@wrc.xerox.com> wrote: > > Greetings and salutations. > > I would like to trim a column from all white spaces. I know how to do it > programmatically, but I would like to do it right to the DB. Is this a > possibility? > > Image this statement: > > CREATE TABLE LSOpenJobs > ( > id integer primary key, > ProjID integer, > subProjID, > parent, > vEmail, > notes, > status > ); > > say that I want o clean up the vEmail column by trimming all whitespaces at > the beginning and the end of the data. I know that trim(vEmail) will do it, > but what would be the command to run to trim all of the existing records? >
SELECT trim(col_name) FROM table If you want to create a new table, just SELECT the desired columns into a new table CREATE TABLE trimmed_table AS SELECT trim(col1), trim(col2)... FROM old_table; > Also, how to I trim specific characters? Say tab, or char(0) or char(X), > etc? I know that I do trim(vEmail,Y), but how do I represent tab? or > newline? etc.? > \t for tab, \n for newline and so on. > thanks, > > josé > -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science ======================================================================= Sent from Madison, Wisconsin, United States _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users