Is there a way to remove all spaces from a specific column for all values?
to replace all spaces :
all spaces
UPDATE `table` SET `col_name` = REPLACE(`col_name`, ' ', '')
to remove all tabs characters:
tabs
UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\t', '' )
to remove all new line characters:
new line
UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\n', '')
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace
to remove the first and last space(s) column:
first and last space(s)
UPDATE `table` SET `col_name` = TRIM(`col_name`)
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_trim
Work request:
SELECT replace(col_name , ' ','') FROM table_name;
So far this is not the case:
SELECT trim(col_name) FROM table_name;
Since the question is how to replace ALL spaces
UPDATE `table` SET `col_name` = REPLACE (REPLACE(REPLACE(`col_name`, ' ', ''), '\t', ''), '\n', '');
Using the query below, you can remove leading and trailing spaces in MySQL.
UPDATE `table_name` SET `col_name` = TRIM(`col_name`);
Just use the following sql, you did:
SELECT replace('Hi How are you',' ', '') output = HiHowareyou