Replace string in MySQL database
This is a MySQL script to use when you want to replcae a string in field.
SET @removeme = "background: silver";
SET @new = "background: #E7E7E7";
UPDATE my_table1 SET my_field1 = REPLACE(my_field1, @removeme, @new) WHERE 1;
UPDATE my_table2 SET my_field2 = REPLACE(my_field2, @removeme, @new) WHERE 1; Source: MySQL Reference manual #REPLACE(str,from_str,to_str)
Replace undesired strings in a MySQL database table. In this case I want to remove the string " " and replace it with " ".
UPDATE orter SET OrtNamn = REPLACE(OrtNamn, " ", " ") WHERE OrtNamn LIKE "% %";This is how you can append the protocol to the URL if its missing. It finds all 'client'-rows that doesn't begin with 'http://' and concatenate the existing url with the protocol string 'http://' at the beginning.
UPDATE client SET url = CONCAT("http://",url) WHERE url NOT LIKE "http://%"Remove duplicates in table column in database with REPLACE() function.
