28 September 2009

0 SQL Tutorial - Find and Replace Text in MySQL Database

SQL Tutorial - Tips2- Find and Replace Text in MySQL

How to Find and Replace Text in MySQL Database using SQL Statements?

The syntax of REPLACE is REPLACE(text_string, from_string, to_string)

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);)

For example:
update vertical_element set vertical_display_name = replace(vertical_display_name, ‘zArchive’ , ‘zNOT_IN_USE’)
The above statement will replace all instances of ‘zArchive’ to ‘zNOT_IN_USE’ in the field ‘vertical_display_name’ of ‘vertical_element’ table.



0 comments:

Feeds Comments

Please give your valuable comments.