Saturday, May 31, 2014

How To Find & Replace String using Mysql Query

if you  find a string in a certain field and replace it with another string in database table. Please use below code.








syntax:
update [table_name] set [field_name] = replace([field_name],’[string_to_find]‘,’[string_to_replace]‘);
or
 UPDATE `table_name`
 SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')

For Exp:
update user set name = replace(name,’Gupta’,'Mishra’);

No comments:

Post a Comment