How to Find and Replace Data in MySQL

Now days everything is stored in database in XML format and sometimes changing anything in that long text field is tedious and time consuming.  In MySQl there is tiny SQLscript that can do automatically for you.  This will find the string that you are looking and then replace with string of your choice.  Here is the sample SQL script.

Syntax:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

Sample:

Code the SQL Script:


update dwdata2.dwdocs_mysql
set company = replace (company, 'Missing Info', 'Steel Corp.');

 

Results:

About onlinejt

Blogger

,

No comments yet.

Leave a Reply

*