remove padding from varchar fields
Posted on 2006-06-14
I just realized that I have a database with a few thousand records with unnecessary padding spaces in the fields fields. I had to export from one DB then upload to MySQL, and didn't realize that the field values were exported with padding spaces.
Anyway, "Smith, John" is coming back from MySQL as "Smith , John ". I put the results straight into HTML, so the extra spaces are ignored, and querying the DB with "Smith" still works . . . but I'd still like to clean up the fields.
Can anyone come up with an SQL statement I could plug into MySQL to strip the unecessary padding from the fields? Unfortunately, I'm much more experienced with MS Access which, for all its shortcomings, has a handy expression builder for putting together scripts to do this kind of thing.