I have this query but I want to change the strings in every field_name found instead of manually changing this. How I can do this ?
update TABLE_NAME
set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
I have this query but I want to change the strings in every field_name found instead of manually changing this. How I can do this ?
update TABLE_NAME
set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
You may use information_schema.columns to build a query for each column
SELECT CONCAT( 'Update table ', table_name,
' set ', column_name, ' = replace(',column_name,', \‘find this string\’, \‘replace found string with this string\’); ')
FROM information_schema.columns
WHERE table_name = '<TableName>'`
This will generate update statements for all of the columns in the table (will save you time and effort to write column names manually).