Replace part of string in mysql table column
UPDATE sometable SET somefield=REPLACE(somefield,'/wordpress//','/wordpress/');
Edit
@Kevin asked me to explain this query, so here we go:
- I assume the basic UPDATE is clear: In all rows of
sometable
assign a new value tosomefield
- the
REPLACE()
function does exactly what it says: It replaces text. In our use case we ant it to take the old value ofsomefield
, then replace all ocurrencies of '/wordpress//' with '/wordpress/' - these two parts taken together mean, in all rows of
sometable
assignsomefield
the value, that results, if you replace all ocurrencies of '/wordpress//' with '/wordpress/' in the old value.