remove padding from varchar fields

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.
Zeek0Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
todd_farmerConnect With a Mentor Commented:
UPDATE table_name SET first_name=TRIM(first_name), last_name=TRIM(last_name);

would clean up existing entries.
0
 
todd_farmerCommented:
Hi Zeek0,

if the first and last name come from different columns, wrap each column name in TRIM(columnname).

Cheers!
0
 
Zeek0Author Commented:
Thanks.  I should have been able to figure that out myself, but you saved me some time sifting through help files/websites. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.