To remove all whitespaces in column MySQL there are several commands you can use.
To remove all whitespaces
, you can using REPLACE
query :
UPDATE `users` SET `username` = REPLACE(`username`, ' ', '');
To remove all tabs
characters, use the following query :
UPDATE `users` SET `username` = REPLACE(`username`, '\t', '' );
To remove all new line
characters, use the following query :
UPDATE `users` SET `username` = REPLACE(`username`, '\n', '');
To remove whitespaces from the beginning
and end
of column, you can using TRIM query :
UPDATE `users` SET `username` = TRIM(`username`);
Hopefully useful.