Replace space (" ") with no space ("") in one column I have a table like this:


ID | Propinsi | Kota |
_________________________
 1 | Aceh     | Denpasar
 2 | Aceh     | Banda Aceh
 3 | Sumatera | Asahan


This table has many rows. The problem is I want to replace the space before the text in column Kota for all rows like this:


ID | Propinsi | Kota |
_________________________
 1 | Aceh     |Denpasar
 2 | Aceh     |Banda Aceh
 3 | Sumatera |Asahan


I searched Google, the function replace in MySQL only affects one row:

SELECT REPLACE(string_column, 'search', 'replace') as Kota


Can someone fix my problem?
Try this:

To show without space:

select trim(kota) from yourtable


To change your data:

update yourtable set kota = trim(kota);


TRIM function is different to REPLACE. REPLACE substitutes all occurrences of a string; TRIM removes only the spaces at the start and end of your string.

If you want to remove only from the start you can use LTRIM instead. For the end only you can use RTRIM.